Jump to content
  • Advertisement
Sign in to follow this  
Xero-X2

messing with images

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

If you intended to correct an error in the post then please contact us.

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 this post


Link to post
Share on other sites
Advertisement
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 this post


Link to post
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 this post


Link to post
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 this post


Link to post
Share on other sites
Sign in to follow this  

  • Advertisement
×

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

We are the game development community.

Whether you are an indie, hobbyist, AAA developer, or just trying to learn, GameDev.net is the place for you to learn, share, and connect with the games industry. Learn more About Us or sign up!

Sign me up!