Click to See Complete Forum and Search --> : Problem to create an alpha surface!


Daniel M
October 14th, 2004, 06:14 PM
Iīm trying to use the IDirectDrawSurface::AlphaBlt method in wince.

Then I have to create an alpha surface and blit that surface to a "normal" (not an alpha surface) surface with the AlphaBlt method, I think....

But when I try to create an alpha surface,I get an invalid parameter as a result!

Is there anybody that has a clue to this error?

These are important flags for the DDPIXELFORMAT in wince:

DDPF_ALPHA: The pixel format describes an alpha-only surface.

DDPF_ALPHAPIXELS: The surface has alpha channel information in the pixel format.

DDPF_ALPHAPREMULT: The color components in the pixel are premultiplied by the alpha value in the pixel. If this flag is set, the DDPF_ALPHAPIXELS flag must also be set. If this flag is not set but the DDPF_ALPHAPIXELS flag is set, the color components in the pixel format are not premultiplied by alpha. In this case, the color components must be multiplied by the alpha value at the time that an alpha-blending operation is performed.

DDPF_RGB: The RGB data in the pixel format structure is valid.


I think I should only use the DDPF_ALPHA and DDPF_RGB flags but I am not sure?

Any comments?

I donīt think I should specify any alphabitdepth as there is no alpha channel information in the RGB_565 pixelformat,isnīt that right?

This is how the code looks like:

Globals:

LPDIRECTDRAW4 lpDD4;
LPDIRECTDRAWSURFACE4 lpddsurf;
SIZE size;

size.cx=486;
size.cy=274;

CreateAlphaSurface(&lpddsurf,&size);

int CreateAlphaSurface( LPDIRECTDRAWSURFACE4* lplpDDS,LPSIZE lpSize )
{
DDSURFACEDESC2 ddsd;
HRESULT res;

ZeroMemory( &ddsd, sizeof ddsd );
ddsd.dwSize = sizeof ddsd;

ddsd.dwFlags=DDSD_CAPS|DDSD_HEIGHT|DDSD_WIDTH|DDSD_PIXELFORMAT;

ddsd.ddsCaps.dwCaps =DDSCAPS_ALPHA;
ddsd.ddpfPixelFormat.dwRBitMask=0xf800;
ddsd.ddpfPixelFormat.dwGBitMask=0x07e0;
ddsd.ddpfPixelFormat.dwBBitMask=0x001f;
ddsd.ddpfPixelFormat.dwRGBBitCount=16;
//ddsd.ddpfPixelFormat.dwAlphaBitDepth=8;
ddsd.ddpfPixelFormat.dwFlags=DDPF_ALPHA|DDPF_RGB;
//ddsd.dwAlphaBitDepth=8;
ddsd.dwWidth = lpSize->cx;
ddsd.dwHeight = lpSize->cy;

// Create the surface.

res=lpDD4->CreateSurface(&ddsd,lplpDDS,NULL);
if(res!=DD_OK)
MessageBox(NULL,L"CreateSurface didnīt worked",NULL,NULL);

switch(res){
case DDERR_INVALIDPARAMS:
MessageBox(NULL,L"CreateSurface INVALIDPARAMS",NULL,NULL);
break;
case DDERR_INVALIDOBJECT:
MessageBox(NULL,L"CreateSurface INVALIDOBJECT",NULL,NULL);
break;
case DDERR_SURFACEBUSY:
MessageBox(NULL,L"CreateSurface SURFACEBUSY",NULL,NULL);
break;
}
}

return 0;
}
Please help anyone, I cannot understand what is wrong, it has to be something with the flags?

Thanks for your help!

DEmberton
October 19th, 2004, 11:17 AM
Did they ever implement any of this? Last I heard it was all (rather unhelpfully) in the documentation but not currently implemented.