Images are not displayed and showing error like "cocos2d: CCTexture2D: Using RGB565 texture since image has no alpha"
box2d-iphone, ccsprite, cocos2d-iphone, opengl-es, texture2d
Solution
I've solved it. Somehow i managed to recreate the image, from which i was creating sprite.
CGImageRef imgRef = [[mutArrAssetPhotos objectAtIndex:i] thumbnail];
UIImage *image = [self updateImage:[UIImage imageWithCGImage:imgRef]];
imgRef = image.CGImage;
CCSprite *paddle = [CCSprite spriteWithCGImage:image.CGImage key:[NSString stringWithFormat:@"%d",i]];
And for updating the image, i redraw it so that i do not get any alpha warnings.The update method is like this :
-(UIImage *) updateImage:(UIImage *)image
{
UIImageView *imgView = [[UIImageView alloc] initWithImage:image];
imgView.frame = CGRectMake(0,50, image.size.width,image.size.height);
image = [self captureImageFrom:imgView];
[imgView release];
return image;
}
-(UIImage *) captureImageFrom:(UIImageView *)view{
UIGraphicsBeginImageContext(view.frame.size);
CGContextRef context = UIGraphicsGetCurrentContext();
[view.layer renderInContext:context];
UIImage *screenShot = UIGraphicsGetImageFromCurrentImageContext();
UIGraphicsEndImageContext();
return screenShot;
}
Problem
I am making an application using Box2D in which i am getting images from Asset Library and displaying them as sprites. here is the code which i have done : Getting Images from asset library : ``` CGImageRef imgRef = [[mutArrAssetPhotos objectAtIndex:i] thumbnail]; ``` Creating Texture2D : ``` CCTexture2D *spriteTexture = [[CCTexture2D alloc]initWithCGImage:imgRef resolutionType:kCCResolutionUnknown]; ``` Creating sprites from textures : ``` CCSprite *paddle = [CCSprite spriteWithTexture:spriteTexture]; ``` This gives me warning in console like : ``` "cocos2d: CCTexture2D: Using RGB565 texture since image has no alpha" ``` Still in simulator it works fine though warning but in device images are not being displayed. But instead if i used : ``` CCSprite *paddle = [CCSprite spriteWithFile:@"img.png"]; ``` it is working fine and is not giving any warning also. Can anyone help please ?? Thanks in Advance.