Jump to content
  • Advertisement


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


Writing to a DirectDraw surface

This topic is 5882 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''m having trouble with writing my loaded bitmap to a DirectX surface. The bitmap loads fine, however when I try to copy the loaded stuff into an offscreen plain the application violently quits without errors. Log file reports that the bitmap loading has begun but never ended. When I logged all steps in the function it turned out to crash when writing to the mem. I''ve used several calculations to get it to work, all failed. This is the code:
// Locking code:

        // Failed to lock. Release the surface, make it NULL and return error

        BitmapSurface = NULL;
        return (FAILED_SURFACE_LOCK);

    // Reserve data for the bitmap. BitmapData is for the bitmap read from

    // the file, BitmapFlipped is the mem for the correct bitmap

    BitmapData    = (WORD *) ddsd.lpSurface;

// Last attempt:

BitmapData[X + (Y * ddsd.lPitch >> 1)] = RGB24TO16(Red, Green, Blue);

// Previous attempt:

BitmapData[Y * (ddsd.lPitch / 2) + X] = RGB24TO16(Red, Green, Blue);
The RGB24TO16 macro:
// Convert 24 bit pixel to 16 bit

#define RGB24TO16(red, green, blue) ( ((red >> 3) << 11) | ((green >> 2) << 5) | (blue >> 3))  
---------------- -Earth is 98% full. Please delete anybody you can.
My Site

Share this post

Link to post
Share on other sites

  • 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!