sprite texture from a web url, the texture become anamorphic in the real machine, but correct in the simulator, so why???

below is the test code:

                NSString* imgurl = @"http://hiphotos.baidu.com/xtwfnfhv00bd/pic/item/a9da6dc911a9890af21fe7b8.jpg";
                NSData* imageData = [NSData dataWithContentsOfURL: [NSURL URLWithString: imgurl]];

                cocos2d::CCImage image;                
                image.initWithImageData((void*)[imageData bytes],imageData.length,(cocos2d::CCImage::EImageFormat)0/*kFmtJpg*/);
                cocos2d::CCTexture2D* texture = new cocos2d::CCTexture2D();
                texture->initWithImage(ℑ);

                cocos2d::CCScene *aScene = cocos2d::CCDirector::sharedDirector()->getRunningScene();
                cocos2d::CCLayer *aLayer = new cocos2d::CCLayer();
                aScene->addChild(aLayer);
                cocos2d::CCSprite * aSprite = cocos2d::CCSprite::spriteWithTexture(texture);
                aLayer->addChild(aSprite);
                aSprite->setPosition(cocos2d::CCPoint(100,100));

How does the original image and anamorphic one look like? Could you paste a screenshot about them?

I have solve this problem already. it all caused by the alpha blending. i don’t know why the jpg file have this blending.
I add a CCBlendFunc ({GL_ONE,GL_ZERO}) to ignore the blending, so that the texture will not show the other one behind it, then the texture show correctly in real machine.

Hi, can you share where do add the ccblendfunc?

cyrus choi wrote:

Hi, can you share where do add the ccblendfunc?

you could search a function call setBlendFunc(ccBlendFunc blendFunc), it exist in ccsprite, CCSpriteBatchNode and so on.
only need to create a blendFunc and set the func, and it will work.

thx, following your method. I done the code.

HI,I used the similar code and got a sprite,but when game paused,the sprite turned to black,do you know why?

I have this working in obj-c using NSData but how can it be done in c++ for multiplatform?