title: cocos2d-x convert UIImage to CCSprite
body: <p>has anyone an idea how to convert a UIImage to cocos2d-x CCSprite.
  My latest attempt was was:
  1. Store the UIImage as png on the phone
  2. Load the png as a CCSprite</p>
  
  <pre><code>[UIImagePNGRepresentation(photo) writeToFile:imagePath atomically:true];
  CCSprite *sprite = CCSprite::spriteWithFile(imagePath);
  </code></pre>
  
  <p>But this crashed in CCObject retain function</p>
  
  <pre><code>void CCObject::retain(void)
  {
      CCAssert(m_uReference &gt; 0, "reference count should greater than 0");
  
      ++m_uReference;
  }
  </code></pre>
  
  <p>And I do not understand how Walzer Wangs suggestion works
  <a href="http://cocos2d-x.org/boards/6/topics/3922" rel="nofollow">http://cocos2d-x.org/boards/6/topics/3922</a></p>
  
  <pre><code>CCImage::initWithImageData(void* pData, int nDataLen, ...)
  CCTexture2D::initWithImage(CCImage* uiImage);
  CCSprite::initWithTexture(CCTexture2D* pTexture);
  </code></pre>