Re: Problem with DirectX6 -> DDSURFACEDESC2 structure and lpSurface
From: Fabian Schmied (REMOVETHISfabianDOTschmied_at_fhs-hagenbergDOTacDOTat)
Date: 12/02/04
- Next message: Exorsus: "Re: Problem with DirectX6 -> DDSURFACEDESC2 structure and lpSurfac"
- Previous message: ProtrackNews: "Re: What functions for intersection?"
- In reply to: Exorsus: "Problem with DirectX6 -> DDSURFACEDESC2 structure and lpSurface"
- Next in thread: Exorsus: "Re: Problem with DirectX6 -> DDSURFACEDESC2 structure and lpSurfac"
- Reply: Exorsus: "Re: Problem with DirectX6 -> DDSURFACEDESC2 structure and lpSurfac"
- Messages sorted by: [ date ] [ thread ]
Date: Thu, 02 Dec 2004 11:09:11 +0100
> i've got one little problem with copying my own data acquired from custom
> image file format into the lpSurface.
> I've tried almost everything, but i simply don't know how to setup
> DDSURFACEDESC2.
> I copied 24-bit RAW RGB image into the lpSurface and there was some sort
> of
> graphics corruption in the loaded image, i think it's all in
> DDSURFACEDESC2......
> So i am interested...what's the problem......???
When locking a surface, you do not yourself setup the DDSURFACEDESC2
(apart from setting its size). It gets filled by the Lock method.
You are probably not doing any color conversion. When you copy anything
onto a locked DirectDraw surface, you need to make sure that you use the
right data format. Writing raw 24-bit RGB data to the surface pointer only
works if the surface has a pixel format of 24-bit RGB (in this order, that
is red first, then green, then blue). Many graphics cards do not have
24-bit surface formats, but actually use 32 bits, with an additional alpha
byte (which may not be used at all).
So, what you need to do is take a look at the surfaceDesc.ddpfPixelFormat
information. It has a dwRGBBitCount member, which tells you, how many bits
each pixel takes (4, 8, 16, 24, or 32). And you need to take a look at the
color masks (dwRBitMask, etc), which tell you how many bits each color (R,
G, B) takes and and where it is located in the pixel value.
Then you need to truncate (or scale) the original 8-bit red, green, and
blue values so that they only take the right amount of bits for the target
surface (for example 5 bits red, 6 bits green, 5 bits blue for a 16-bit
surface with "RGB565" pixel format; note that other formats are also
possible, e.g. BGR and similar). Now you shift the truncated values to
their positions in the new pixel value and combine them using bitwise OR.
Take a look at this [1] tutorial by Michael Fötsch, he explains all of
this very well.
Fabian
[1] http://www.geocities.com/foetsch/locking/locking.htm
- Next message: Exorsus: "Re: Problem with DirectX6 -> DDSURFACEDESC2 structure and lpSurfac"
- Previous message: ProtrackNews: "Re: What functions for intersection?"
- In reply to: Exorsus: "Problem with DirectX6 -> DDSURFACEDESC2 structure and lpSurface"
- Next in thread: Exorsus: "Re: Problem with DirectX6 -> DDSURFACEDESC2 structure and lpSurfac"
- Reply: Exorsus: "Re: Problem with DirectX6 -> DDSURFACEDESC2 structure and lpSurfac"
- Messages sorted by: [ date ] [ thread ]
Relevant Pages
|