[Help] failed to use CCRenderTexture to scale texture


#1

Becuase of our project, we have to zoom in some textures in game.
At first I tried to write the following function for it,
at least with my android mobile, it works fine.

But recently we try it on some Android 4.x mobile,
some textures can’t been displayed…

Specially, I found on the same mobile hardware but different OS,
same mobile hardware (china mobile XiaoMi 1)
different OS (2.x is no problem, 4.x has display problem)

btw, we’re using cocos2d-x SDK 2.0.3.
Please give us some advices,
thanks a lot.

@
CCImage * CGraphicUtil::createZoomImage(CCImage * pcOriImage, float fZoomFactorX, float fZoomFactorY)
{
if (pcOriImage == NULL)
{
return NULL;
}

CCTexture2D * pcOriTexture = new CCTexture2D();
pcOriTexture~~>initWithImage;
pcOriTexture~~>autorelease();

pcOriTexture~~>setAliasTexParameters;
int w = pcOriTexture~~>getPixelsWide() * fZoomFactorX;
int h = pcOriTexture~~>getPixelsHigh * fZoomFactorY;
CCRenderTexture * pcTempRenderTex = CCRenderTexture::create;
pcTempRenderTex~~>beginWithClear(0.0f, 0.0f, 0.0f, 0.0f);
pcOriTexture~~>drawInRect);
pcTempRenderTex~~>end();

CCImage * pcRetImage = pcTempRenderTex~~>newCCImage;
pcRetImage~~>autorelease();

CC_SAFE_RELEASE(pcTempRenderTex);
CC_SAFE_RELEASE(pcOriTexture);

return pcRetImage;
}@