messing with images

This topic is 4722 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

Recommended Posts

ok this is gonna seem really simple, at least It should... the following code 'should' make the img 32 bit, and inlarge it to a given size.
    BYTE * NData;
NData = new BYTE[4 * Nx * Ny];
memset( NData, 0, 4 * Nx * Ny );
for ( int y = 0; y < Y; y++ )
for ( int x = 0; x < X; x++ )
for ( int R = 0; R < M; R++ )
NData[( x + y * Nx ) * 4 + R] = Data[( x + y * X ) * M + R];

for the life of me everything I can think of says this should work, yet it dosn't it messes with the alignment of colors, I just need some one to point out whats wrong, cause im blinded by something M = previous colors per pixel R = color offset, weight its r,g,b X,Y = previous X,Y dimentions Nx, Ny = new X,Y Dimentions Data = old img NData = new img I'm nearly pulling my hair out trying to realize what in the world is wrong with it... the most curious thing is, if the img to be resized has a width of a power of 2 this works perfectly...... maybe thats why im so confused... please help! [Edited by - Xero-X2 on June 17, 2005 4:12:48 AM]

Share on other sites
Im thinking the problem would be with your routine that displays the image. It needs to be able to handle images that aren't a neat power of 2 size. You could either pad it out during this resizing routine, or do it in your drawing routine.

Share on other sites
nope, cause thats what this routine is for, padding the img to be a power of 2, and adding an alpha channel, also it has been tested in two ways, one saving as a bmp, and 2 being rendered in opengl. the bmp would have no problems with non power of 2 imgs.

Share on other sites
What is the source of your images? The bitmap file format pads each line to the nearest multiple of 4 bytes, i.e. the 2 by 3 image:

RGB
BGR

Stored as a 24 bit bitmap would be:

0  0  255   0  255  0   255  0  0   0  0  0   255  0  0   0  255  0   0  0  255   0  0  0
|  pixel 1  |  pixel 2  |  pixel 3  |   pad   |  pixel 4  |  pixel 5  |  pixel 6  |   pad   |

Enigma

Share on other sites
Hmm that might be the problem, I hate the bmp format more and more with each passing use...

Share on other sites
Thank you very much, that fixed it!

• 19
• 10
• 19
• 14
• 19