• Advertisement

Archived

This topic is now archived and is closed to further replies.

DD7 - Please help me understand surface pitch

This topic is 5507 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

I have a windowed DX app. The window is 640x480 with a backbuffer of 640x480 When I lock the backbuffer, I get a pitch of 0xA00(2560) My desktop res is 1280x1024 1280*2 = 2560 I am writing data to the backbuffer. So far I have not gotten the data to look right yet. Knowing the pitch, what is the right way(equation) to write data to a 640x480 backbuffer, one X scanline, then the neat scanline on the Y? Thanks

Share this post


Link to post
Share on other sites
Advertisement
The pitch is the number of BYTES (not pixels) in each line of the screen. Often, lpitch is the number of pixels horisontally * the number of bytes for each pixel, but not always, it can be a larger number too. From what you're saying, i'd guess you're running in 16-bit color, right? (1280*2=2560)

If you want to write a pixel to a certain location on a 16-bit screen, you do:

USHORT screenPointer;

screenPointer[y*(pitch/2)+x] = color;

Note that I divide pitch with 2, because in 16-bit mode, every pixel is 2 bytes.

Hope that helps

/John

[edited by - FunkyTune on January 21, 2003 6:23:25 AM]

Share this post


Link to post
Share on other sites
Umm... actually I think he''s running under 32 bit color with a width of 640? (: good luck (; 4 bytes per pixel in the 640 x 480 window.

Share this post


Link to post
Share on other sites
Ooops, I forgot to says me desktop is 32-bit.

quote:

screenPointer[y*(pitch/2)+x] = color;

Note that I divide pitch with 2, because in 16-bit mode, every pixel is 2 bytes.



So i should divide by 4 as every pixel is 4 bytes in 32-bit mode.

Thanks.

Share this post


Link to post
Share on other sites

  • Advertisement