title: [cocos2dx android]Rendering CCSprite using raw data from Bitmap
body: <p>I am trying to fetch an image from a URL into a Bitmap and then using the raw data from the Bitmap am trying to create a CCSprite. The issue here is that the image is corrupted when I display the sprite. I created a standalone android only application(no cocos2dx) and used the same code to fetch and display the Bitmap and its displayed correctly. Any reason why the image is not being properly rendered in cocos2dx? </p>
  
  <p>My code to fetch the image from the URL is:</p>
  
  <pre><code>String urlString = "http://www.mathewingram.com/work/wp-content/themes/thesis/rotator/335f69c5de_small.jpg";//http://graph.facebook.com/"+user.getId()+"/picture?type=large";
  Bitmap pic = null;
  pic = BitmapFactory.decodeStream((InputStream) new URL(urlString).getContent());
  int[] pixels = new int[pic.getWidth() * pic.getHeight()];
  pic.getPixels(pixels, 0, pic.getWidth(), 0, 0,pic.getWidth(),pic.getHeight());
  int len = pic.getWidth()* pic.getHeight();
  nativeFbUserName(pixels,len,pic.getWidth(), pic.getHeight());
  </code></pre>
  
  <p>The function "nativeFbUserName" is a call to a native c++ function which is :</p>
  
  <pre><code>void Java_com_WBS_Test0001_Test0001_nativeFbUserName(JNIEnv *env, jobject thiz,jintArray name, jint len, jint width, jint height) {
  jint *jArr = env-&gt;GetIntArrayElements(name,NULL);
  int username[len];
  for (int i=0; i&lt;len; i++){
      username[i] = (int)jArr[i];
  }
  HelloWorld::getShared()-&gt;picLen = (int)len;
  HelloWorld::getShared()-&gt;picHeight = (int)height;
  HelloWorld::getShared()-&gt;picWidth = (int)width;
  HelloWorld::getShared()-&gt;saveArray(username);
  HelloWorld::getShared()-&gt;schedule(SEL_SCHEDULE(&amp;HelloWorld::addSprite),0.1);
  }
  void HelloWorld::saveArray(int *arrayToSave)
  {
  arr = new int[picLen];
  for(int i = 0; i &lt; picLen; i++){
      arr[i] = arrayToSave[i];
  }
  }
  void HelloWorld::addSprite(float time)
  {
  this-&gt;unschedule(SEL_SCHEDULE(&amp;HelloWorld::addSprite));
  CCTexture2D *tex = new CCTexture2D();
  bool val = tex-&gt;initWithData(arr,(cocos2d::CCTexture2DPixelFormat)0,picWidth,picHeight, CCSizeMake(picWidth,picHeight));
  CCLog("flag is %d",val);
  CCSprite *spriteToAdd = CCSprite::createWithTexture(tex);
  spriteToAdd-&gt;setPosition(ccp(500, 300));
  this-&gt;addChild(spriteToAdd);
  }
  </code></pre>
  
  <p>Edit:
  So I found this link <a href="https://stackoverflow.com/questions/5010545/access-to-raw-data-in-argb-8888-android-bitmap?answertab=votes#tab-top">Access to raw data in ARGB_8888 Android Bitmap</a> that states that it might be a bug. Has anyone found a solution to this? </p>