Jump to content
  • Advertisement
Sign in to follow this  
dani100001

Problem trying to create an alpha surface?

This topic is 5393 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 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! [Edited by - Coder on October 14, 2004 11:00:33 PM]

Share this post


Link to post
Share on other sites
Advertisement
Sign in to follow this  

  • Advertisement
×

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

GameDev.net is your game development community. Create an account for your GameDev Portfolio and participate in the largest developer community in the games industry.

Sign me up!