Image Scaling problem

My app contains same images ,which has different dimensions .for example . i have 160x120 dimension png ,and a 320x 240 dimension png .there are the same picture, as you know , memory use can be very sensitive in a game . so i end up having 320x240 png ,and scalling it to 160x120 using the same texture.
but the scalled 160x120 png is not very real.kind of lacking fidelity
so how to avoid it ?

i am sorry for my bad English ,hope you can understand.
any feedback are very welcome , thank you in advance.:slight_smile:

I’m not sure I understand. Generally, downscaling an image doesn’t imply any lack of fidelity. The problem comes when you upscale a small image.

When you say “but the scalled 160x120 png is not very real.kind of lacking fidelity”, do you mean you are upscaling your 160x120 image to 2X or downscaling your 320x240 image to 0.5X ? In the first case, of course it’s going to look bad : you need to load the 320x240 image instead. In the second case, there shouldn’t be any problem.

Another strange thing you said is “scalling it to 160x120 using the same texture.” What do you mean by that ? Because your two images are going to be different textures, CCTextureCache takes care of that.

Last but not least “memory use can be very sensitive in a game” : you have to be careful, but if you don’t go overboard and use assets depending on the device screen size and use the easy cocos2d optimizations, you shouldn’t have much problems.

Thank you for your answer.
“scalling it to 160x120 using the same texture” means i downscale the 320x240 image…
in my case , downscaling can cause lack of fidelity,image dones’t look good , something like alias .
i simulate my case using photoshop .you can see the image on the right donesn’t look so good…so it’s a problem. .

You could try to experiment with mipmaps to get better visual results when you scale down your image. However you can do this only with POT textures (width and height must be power of two) - if you are using spritesheets this shouldn’t be a problem.

Example:
sprite->getTexture()->generateMipmap(); ccTexParams tp = { GL_NEAREST_MIPMAP_NEAREST , GL_LINEAR, GL_CLAMP_TO_EDGE, GL_CLAMP_TO_EDGE}; // you can try different values for the first parameter here sprite->getTexture()->setTexParameters(&tp);