lPitch and DDraw surfaces giving me hell!!!

Started by
3 comments, last by BinaryOne 21 years, 8 months ago
I am currently writing a bitmap load function that takes a bitmap from file and gets it onto a ddraw surface. I am having problems transfering the bitmap from my bitmap buffer to a surface. To define the surface dimensions I use the bitmaps dimensions drawn from its header. When I enter certain values the bitmap becomes skewed. This is because the surface lPitch is greater than the bitmap width. All powers of 2 work and also the various screen resolution sizes from 640x480 dividing the width and height by 2 each time all worked. When there is a variation between lPitch and width the lPitch is always larger, by a multiple of 4 pixels. From tests the width(in bytes) values that have the problem finish with a value in the 60 range. The only time a crash occurs without deviation is when I select a bitmap height of 479 and i suspect this is because of trampling of memory. I am working at 640x480 with 32bpp. Your help would be greatly appreciated Thanx!!!!
Advertisement
I guess I''m not understanding all of the problem here... if you know that the pitch difference is skewing your bitmap, then why don''t you just account for it in your code?


Don''t listen to me. I''ve had too much coffee.
I tried that already and it didn''t work, even if it did I would need to know why i get the error, whether it is because of me or the hardware i am using thanx neway!!! any other suggestions?
I tried that already and it didn''t work, even if it did I would need to know why i get the error, whether it is because of me or the hardware i am using thanx neway!!! any other suggestions?
I suggest you debug.

Let's say I have a bitmap (declared as a char *) of height bh, width bw, and pixel-width bpw, and I want to copy it to a texture (declared as a char *)with height th, width tw, and pitch tp. Watch closely.


    for(int y=0; y<bh; ++y){    memcpy(texture + (tp * bpw * y), bitmap + (bw * bpw * y), sizeof(char) * bpw * bw);}    



Don't listen to me. I've had too much coffee.

[edited by - sneftel on August 13, 2002 8:18:02 PM]

This topic is closed to new replies.

Advertisement