View Full Version : Resize Textures
Hello again :)
I wrote a code that loads a free-sized bitmap into memory, and fills it up to a loadable texture size like 128x128 for example. But in some cases, the texture doesnt look right anymore after that. I guess my code is wrong, but I dont know how to solve. Is there any example code I can learn from?
If anybody wants to take a look at, I can post here my code I have and maybe find the mistake :)
Thank your for your help
There's lots of code out there to learn from. Google, but try to get some sleep sometime.
Posting your code is a good idea if you want people to quickly identify your problem, especially if it's a simple/short one, and it's related to opengl ;-)
unsigned char *d_rgba=NULL;
d_rgba=new unsigned char[d_rgba_size];
}rx_pot, ry_pot hold the real size of the image, eg 120x90
nx_pot, ny_pot hold the size of the texture to fill up, eg 128x128. This got already calculated in the code before but I didn't post it, as it works.
I guess the problem is in the loop, where the pixels get filled up. As you can see, there's also color-keying implemented. This works fine. I just guess, filling the data from the smaller array into the bigger one works wrong. But I don't know how to fix it at the moment.
Who can help?
10-17-2005, 12:05 PM
I see two problems in that code snippet.
Your memset will only clear the first (maybe) four bytes of your new image buffer. sizeof(d_rgba) is the size of an "unsigned char *" (a pointer), not the whole size of your allocated array. Your index into the new image array is wrong, after the first row. You are correctly accounting for the different pixel sizes (rgb vs rgba) in the two buffer, but not for the different row sizes.
Powered by vBulletin® Version 4.2.2 Copyright © 2014 vBulletin Solutions, Inc. All rights reserved.