当前位置: 首页>>代码示例>>C++>>正文


C++ LPDIRECTDRAWSURFACE::Lock方法代码示例

本文整理汇总了C++中LPDIRECTDRAWSURFACE::Lock方法的典型用法代码示例。如果您正苦于以下问题:C++ LPDIRECTDRAWSURFACE::Lock方法的具体用法?C++ LPDIRECTDRAWSURFACE::Lock怎么用?C++ LPDIRECTDRAWSURFACE::Lock使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在LPDIRECTDRAWSURFACE的用法示例。


在下文中一共展示了LPDIRECTDRAWSURFACE::Lock方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。

示例1: lock

	bool lock(LPDIRECTDRAWSURFACE dd,_TPixelsRef& out_pixelsRef){
		DDSURFACEDESC ddsdDest; 
		memset(&ddsdDest,0,sizeof(ddsdDest));
		ddsdDest.dwSize=sizeof(ddsdDest);
		//ddsdDest.dwFlags=DDSD_LPSURFACE | DDSD_PITCH | DDSD_WIDTH | DDSD_HEIGHT;
		HRESULT ddrval=dd->Lock(NULL,&ddsdDest,DDLOCK_WAIT,NULL);
		if( ddrval == DDERR_SURFACELOST ) {
			ddrval = m_ddsprimary->Restore();
			if( ddrval!= DD_OK )
				return false;
			dd->Lock(NULL,&ddsdDest,DDLOCK_WAIT,NULL);
		}

		if (ddsdDest.lpSurface==0) return false;

		if (ddsdDest.lPitch<=4){
			out_pixelsRef.pdata=ddsdDest.lpSurface;//获得页面首地址
			out_pixelsRef.width=ddsdDest.dwHeight;
			out_pixelsRef.height=ddsdDest.dwWidth;
			out_pixelsRef.byte_width=-out_pixelsRef.width*ddsdDest.lPitch;
			((Pixels32Ref&)out_pixelsRef).reversal();
		}else{
			out_pixelsRef.pdata=ddsdDest.lpSurface;//获得页面首地址
			out_pixelsRef.width=ddsdDest.dwWidth;
			out_pixelsRef.height=ddsdDest.dwHeight;
			out_pixelsRef.byte_width=ddsdDest.lPitch;
		}

		return true;
	}
开发者ID:liujw,项目名称:SceneEditor,代码行数:30,代码来源:DDrawImport.cpp

示例2: flip_fullscreen

void dd_Window::flip_fullscreen()
{
	int i=0;
	HRESULT hr;

	//hack for 320x200 letterboxing
	if(xres == 320 && yres == 200)
	{
		hr = dx_bs->BltFast(0,20,dx_os,NULL,DDBLTFAST_WAIT | DDBLTFAST_NOCOLORKEY);
		DDBLTFX ddbltfx;
		memset(&ddbltfx, 0, sizeof(DDBLTFX));
		ddbltfx.dwSize = sizeof(DDBLTFX);
		ddbltfx.dwFillColor = 0;
		RECT rBlit;
		rBlit.left = 0; rBlit.top = 0; rBlit.right = 320; rBlit.bottom = 20;
		dx_bs->Blt(&rBlit, 0, 0, DDBLT_COLORFILL | DDBLT_WAIT, &ddbltfx);
		rBlit.left = 0; rBlit.top = 220; rBlit.right = 320; rBlit.bottom = 240;
		dx_bs->Blt(&rBlit, 0, 0, DDBLT_COLORFILL | DDBLT_WAIT, &ddbltfx);
	}
	//regular case
	else
		hr = dx_bs->BltFast(0,0,dx_os,NULL,DDBLTFAST_WAIT | DDBLTFAST_NOCOLORKEY);


	if(hr==DDERR_SURFACELOST)
	{
		dx_bs->Restore();
		dx_os->Restore();
		dx_bs->BltFast(0,0,dx_os,NULL,DDBLTFAST_WAIT | DDBLTFAST_NOCOLORKEY);
	}

	hr=dx_ps->Flip(0,DDFLIP_WAIT | DDFLIP_NOVSYNC);
	//dx_ps->Flip(0,0);

	if(hr==DDERR_SURFACELOST)
	{
		dx_ps->Restore();
		hr=dx_ps->Flip(0,DDFLIP_WAIT | DDFLIP_NOVSYNC);
	}


	hr=dx_os->Lock(0,&dx_osd,DDLOCK_SURFACEMEMORYPTR | DDLOCK_WRITEONLY | DDLOCK_WAIT,0);
	if(hr==DDERR_SURFACELOST)
	{
		dx_os->Restore();
		hr=dx_os->Lock(0,&dx_osd,DDLOCK_SURFACEMEMORYPTR | DDLOCK_WRITEONLY | DDLOCK_WAIT,0);
	}
	dx_os->Unlock(0);

	img->data=(quad*)dx_osd.lpSurface;
	img->pitch=dx_osd.lPitch/vid_bytesperpixel;
}
开发者ID:Bananattack,项目名称:verge3,代码行数:52,代码来源:vid_ddbase.cpp

示例3: DrawBegin

BOOL DrawBegin()
{
    DDSURFACEDESC ddsd;
    HRESULT       result;

    if (bSaveFramebuffer || !useDirectDraw)
    {
        scrpitch = scratch_pitch;
        scrbuf = scratch_buffer;
        return TRUE;
    }

    if (BackSurface == NULL)
    {
        return FALSE;
    }

    ZeroMemory(&ddsd, sizeof(ddsd));
    ddsd.dwSize = sizeof(ddsd);
    result = BackSurface->Lock(NULL, &ddsd, DDLOCK_WAIT, NULL);
    if (result != DD_OK)
    {
        scrpitch = scratch_pitch;
        scrbuf = scratch_buffer;
        return TRUE;
    }

    scrpitch = ddsd.lPitch;
    scratch_pitch = scrpitch;
    scrbuf = (BYTE*)ddsd.lpSurface;

    return TRUE;
}
开发者ID:Almamu,项目名称:homeworld,代码行数:33,代码来源:draw.cpp

示例4: DDColorMatch

/*
 * DDColorMatch:
 *    Matches a color (RGB) with a surface
 */
DWORD DDColorMatch(LPDIRECTDRAWSURFACE pdds, COLORREF rgb)
{
    COLORREF rgbT;
    HDC hdc;
    DWORD dw = CLR_INVALID;
    DDSURFACEDESC ddsd;
    HRESULT hres;
    
    //  use GDI SetPixel to color match for us
    if (rgb != CLR_INVALID && pdds->GetDC(&hdc) == DD_OK) {
        rgbT = GetPixel(hdc, 0, 0);             // save current pixel value
        SetPixel(hdc, 0, 0, rgb);               // set our value
        pdds->ReleaseDC(hdc);
    }
    
    // now lock the surface so we can read back the converted color
    ddsd.dwSize = sizeof(ddsd);
    while ((hres = pdds->Lock(NULL, &ddsd, 0, NULL)) == DDERR_WASSTILLDRAWING);
    
    if (hres == DD_OK) {
        dw = *(DWORD *)ddsd.lpSurface; // get DWORD
        if (ddsd.ddpfPixelFormat.dwRGBBitCount < 32) {
            dw &= (1 << ddsd.ddpfPixelFormat.dwRGBBitCount) - 1;  // mask it to bpp
        }
        pdds->Unlock(NULL);
    }
    
    //  now put the color that was there back.
    if (rgb != CLR_INVALID && pdds->GetDC(&hdc) == DD_OK) {
        SetPixel(hdc, 0, 0, rgbT);
        pdds->ReleaseDC(hdc);
    }
    
    return dw;
}
开发者ID:mreiferson,项目名称:dod,代码行数:39,代码来源:dodddraw.cpp

示例5: clear_buffers

static void clear_buffers(void)
{
    LPDIRECTDRAWSURFACE surfs[] = {BackSurface, PrimarySurface};
    LPDIRECTDRAWSURFACE surf;
    DDSURFACEDESC ddsd;
    BYTE* psurf;
    int i, y;

    for (i = 0; i < 2; i++)
    {
        ZeroMemory(&ddsd, sizeof(ddsd));
        ddsd.dwSize = sizeof(ddsd);

        surf = surfs[i];
        if (surf->Lock(NULL, &ddsd, DDLOCK_WAIT, NULL) != DD_OK)
        {
            continue;
        }

        for (y = 0; y < SCRHEIGHT; y++)
        {
            psurf = (BYTE*)ddsd.lpSurface + y*ddsd.lPitch;
            ZeroMemory(psurf, 2*SCRWIDTH);
        }

        surf->Unlock(NULL);
    }
}
开发者ID:Almamu,项目名称:homeworld,代码行数:28,代码来源:draw.cpp

示例6: memset

static gxj_pixel_type*
startDirectPaint(int &dstWidth, int &dstHeight, int &dstYPitch) {
    gxj_pixel_type *dst = NULL;

#if JWC_WINCE_USE_DIRECT_DRAW
    if (isScreenRotated() || !isScreenFullyVisible() || editBoxShown) {
        /* DDraw is not very reliable on an rotated screen. Use GDI instead. */
        return NULL;
    }

    if (g_pDD == NULL) {
        /* DirectDraw failed to initialize. Let's use GDI to Blit to the LCD. */
        return NULL;
    }

    HRESULT hRet;
    DDSURFACEDESC surfaceDesc;
    DDSURFACEDESC ddsd;

    if (g_pDDSPrimary == NULL) {
        /* Create the primary surface with 0 back buffer */
        memset(&ddsd, 0, sizeof(ddsd));
        ddsd.dwSize = sizeof(ddsd);
        ddsd.dwFlags = DDSD_CAPS;
        ddsd.ddsCaps.dwCaps = DDSCAPS_PRIMARYSURFACE ;
        hRet = g_pDD->CreateSurface(&ddsd, &g_pDDSPrimary, NULL);
        if (hRet != DD_OK) {
            g_pDDSPrimary = NULL;
            return NULL;
        }
    }

    surfaceDesc.dwSize = sizeof(surfaceDesc);
    hRet = g_pDDSPrimary->Lock(NULL, &surfaceDesc,
                               DDLOCK_DISCARD | DDLOCK_WRITEONLY, NULL);
    if (hRet == DD_OK) {
        dst = (gxj_pixel_type*)surfaceDesc.lpSurface;
        dstWidth = surfaceDesc.dwWidth;
        dstHeight = surfaceDesc.dwHeight;
        dstYPitch = surfaceDesc.lPitch;
    } else {
        /* Release the DD resources. Maybe we'd get lucky and can allocate
         * it next time.
         */
        g_pDDSPrimary->Release();
        g_pDDSPrimary = NULL;
        return NULL;
    }
#else
    if (editBoxShown) {
        return NULL;
    }
    dstWidth = gxDispProps.cxWidth;
    dstHeight = gxDispProps.cyHeight;
    dstYPitch = gxDispProps.cbyPitch;
    dst = (gxj_pixel_type*)GXBeginDraw();
#endif

    return dst;
}
开发者ID:sfsy1989,项目名称:j2me,代码行数:60,代码来源:winceapp_export.cpp

示例7: CreateSurfPCXResource

LPDIRECTDRAWSURFACE CreateSurfPCXResource(WORD PCXNum, bool VidMem)
{
	HRSRC FResource = FindResource(HInstance, MAKEINTRESOURCE(PCXNum), RT_RCDATA);
	if(FResource == NULL)
		IDDrawSurface::OutptTxt("FResource NULL");

	HGLOBAL LResource = LoadResource(HInstance, FResource);
	if(LResource == NULL)
		IDDrawSurface::OutptTxt("LResource NULL");

	LPVOID PCXBuf = LockResource(LResource);
	if(PCXBuf == NULL)
		IDDrawSurface::OutptTxt("PCXBuf NULL");

	pcx_picture_typ PCXPic;

	//PCXPic.buffer= (unsigned char *)malloc (	SizeofResource ( HInstance, FResource));
	PCX2BitMap((unsigned char*)PCXBuf, &PCXPic, 0);
	int Height = PCXPic.header.height-PCXPic.header.y+1;
	int Width = PCXPic.header.width-PCXPic.header.x+1;
	LPDIRECTDRAWSURFACE RetSurf;

	DDSURFACEDESC ddsd;
	DDRAW_INIT_STRUCT(ddsd);
	ddsd.dwFlags = DDSD_CAPS | DDSD_WIDTH | DDSD_HEIGHT;
	if(VidMem)
		ddsd.ddsCaps.dwCaps = DDSCAPS_OFFSCREENPLAIN | DDSCAPS_SYSTEMMEMORY;
	else
		ddsd.ddsCaps.dwCaps = DDSCAPS_OFFSCREENPLAIN;
	ddsd.dwWidth = Width;
	ddsd.dwHeight = Height;

	if( DD_OK!=((LPDIRECTDRAW)LocalShare->TADirectDraw)->CreateSurface(&ddsd, &RetSurf, NULL))
	{
		return NULL;
	}
	DDRAW_INIT_STRUCT(ddsd);

	RetSurf->Lock(NULL, &ddsd, DDLOCK_SURFACEMEMORYPTR | DDLOCK_WAIT, NULL);

	unsigned char *SurfPTR = (unsigned char*)ddsd.lpSurface;
	if (NULL!=PCXPic.buffer)
	{
		if (NULL!=SurfPTR)
		{
			for(int i=0; i<Height; i++)
			{
				memcpy(&SurfPTR[i*ddsd.lPitch], &PCXPic.buffer[i*Width], Width);
			}
		}

		delete [] PCXPic.buffer;
	}

	RetSurf->Unlock(NULL);
	return RetSurf;
}
开发者ID:jchristi,项目名称:taddraw,代码行数:57,代码来源:pcxread.cpp

示例8: RestoreFromPCX

//loads the PCX picture onto an existing surface
void RestoreFromPCX(WORD PCXNum, LPDIRECTDRAWSURFACE lpSurf)
{
	HRSRC FResource = FindResource(HInstance, MAKEINTRESOURCE(PCXNum), RT_RCDATA);
	if(FResource == NULL)
		IDDrawSurface::OutptTxt("FResource NULL");

	HGLOBAL LResource = LoadResource(HInstance, FResource);
	if(LResource == NULL)
		IDDrawSurface::OutptTxt("LResource NULL");

	LPVOID PCXBuf = LockResource(LResource);
	if(PCXBuf == NULL)
		IDDrawSurface::OutptTxt("PCXBuf NULL");

	pcx_picture_typ PCXPic;

	PCX2BitMap((unsigned char*)PCXBuf, &PCXPic, 0);
	int Height = PCXPic.header.height-PCXPic.header.y+1;
	int Width = PCXPic.header.width-PCXPic.header.x+1;

	DDSURFACEDESC ddsd;
	DDRAW_INIT_STRUCT(ddsd);

	lpSurf->Lock(NULL, &ddsd, DDLOCK_SURFACEMEMORYPTR | DDLOCK_WAIT, NULL);

	unsigned char *SurfPTR = (unsigned char*)ddsd.lpSurface;

	if ((NULL!=PCXPic.buffer))
	{
		if ((NULL!=SurfPTR)&&(NULL!=PCXPic.buffer))
		{
			for(int i=0; i<Height; i++)
			{
				memcpy(&SurfPTR[i*ddsd.lPitch], &PCXPic.buffer[i*Width], Width);
			}
		}
		delete [] PCXPic.buffer;
	}



	lpSurf->Unlock(NULL);
}
开发者ID:jchristi,项目名称:taddraw,代码行数:44,代码来源:pcxread.cpp

示例9: Update

bool WinDrawDDS::Update(LPDIRECTDRAWSURFACE dds, const RECT& rect)
{
	if (rect.left >= rect.right || rect.top >= rect.bottom)
		return false;

	HRESULT r;
	DDSURFACEDESC ddsd;
	memset(&ddsd, 0, sizeof(ddsd));
	ddsd.dwSize = sizeof(ddsd);
	
	RECT rectdest;
	rectdest.left	= ltc.x + rect.left;
	rectdest.right	= ltc.x + rect.right;
	rectdest.top	= ltc.y + rect.top;
	rectdest.bottom = ltc.y + rect.bottom;

	r = dds->Lock(&rectdest, &ddsd, DDLOCK_WAIT | DDLOCK_WRITEONLY, 0);
	LOGDDERR("ddsk->Lock", r);
	if (r != DD_OK)
		return false;
	
	const uint8* src = image + rect.left + (rect.top * width);
	uint8* dest = (uint8*) ddsd.lpSurface;

	for (int y = rect.top; y < rect.bottom; y++)
	{
		uint8 *d = dest;
		for (int x =0; x < (rect.right - rect.left); x++) {
			*d++ = palentry[src[x]].peBlue;
			*d++ = palentry[src[x]].peGreen;
			*d++ = palentry[src[x]].peRed;
			if (m_bpp == 4) {
				*d++ = 00;
			}
		}
		dest += ddsd.lPitch;
		src  += width;
	}

	dds->Unlock(ddsd.lpSurface);
	return true;
}
开发者ID:pololei,项目名称:m88,代码行数:42,代码来源:DrawDDS.cpp

示例10: sizeof

static 	u8 *screen_lock(u32 *pitch)
{
	HRESULT ret;
	DDSURFACEDESC ddsc;

	dd_restore();
	ddsc.dwSize = sizeof(ddsc);
	ret = lpDDSPrimary->Lock(&screenrect, &ddsc, DDLOCK_WAIT, 0);
	if (ret != DD_OK)
	{
		module_logger(&win32DirectDrawVideo, _L|LOG_ERROR|LOG_USER, _("error in Lock with %8X\n"),ret);
		return NULL;
	}

	/* locked */
	//log("lpSurface = %p\n", ddsc.lpSurface);

	*pitch = ddsc.lPitch;
	return (u8 *)ddsc.lpSurface;
}
开发者ID:eswartz,项目名称:emul,代码行数:20,代码来源:video_win32_ddraw.cpp

示例11: q_lock

void q_lock()
{
    if (locked) {
        qWarning("Direct Painter already locked (QDirectPainter::lock())");
        return;
    }
    locked = true;


    memset(&ddsSurfaceDesc, 0, sizeof(ddsSurfaceDesc));
    ddsSurfaceDesc.dwSize = sizeof(ddsSurfaceDesc);

    HRESULT h = g_pDDSSurface->Lock(0, &ddsSurfaceDesc, DDLOCK_WRITEONLY, 0);
    if (h != DD_OK)
        qDebug() << "GetSurfaceDesc failed!";

    width = ddsSurfaceDesc.dwWidth;
    height = ddsSurfaceDesc.dwHeight;
    bitCount = ddsSurfaceDesc.ddpfPixelFormat.dwRGBBitCount;
    pitch = ddsSurfaceDesc.lPitch;
    buffer = ddsSurfaceDesc.lpSurface;
}
开发者ID:Mr-Kumar-Abhishek,项目名称:qt,代码行数:22,代码来源:ddhelper.cpp

示例12: GetPitch

DWORD GetPitch()
{
    DDSURFACEDESC ddsd;
    HRESULT       result;

    if (BackSurface == NULL)
    {
        return FALSE;
    }

    ZeroMemory(&ddsd, sizeof(ddsd));
    ddsd.dwSize = sizeof(ddsd);
    result = BackSurface->Lock(NULL, &ddsd, DDLOCK_WAIT, NULL);
    if (result != DD_OK)
    {
        return 0;
    }

    DWORD pitch = ddsd.lPitch;

    BackSurface->Unlock(NULL);

    return pitch;
}
开发者ID:Almamu,项目名称:homeworld,代码行数:24,代码来源:draw.cpp

示例13: mfc_render_do

void mfc_render_do(void *mfc_render_handle, unsigned char *pImg, int width, int height, int img_type)
{
	_MFC_RENDER_OVERLAY   *pMFC_RENDER_OVERLAY;

	DDSURFACEDESC          ddsd;
	HRESULT                hRet;

	LPDIRECTDRAWSURFACE    pDDSOverlay;	// Overlay Surface.

	unsigned char *pSurf;
	int            y_size, u_size;


	switch (img_type) {
	case MFC_RENDER_IMAGE_TYPE_YUV420:
	case MFC_RENDER_IMAGE_TYPE_RGB565:
	case MFC_RENDER_IMAGE_TYPE_YV12:
		break;

	default:
		PRINT_ERRMSG(TEXT("img_type is not supported."));
		return;
	}


	if (mfc_render_handle == NULL) {
		PRINT_ERRMSG(TEXT("\nmfc_render_handle is NULL."));
		return;
	}
	if (pImg == NULL) {
		PRINT_ERRMSG(TEXT("Input image is NULL."));
		return;
	}

	pMFC_RENDER_OVERLAY = (_MFC_RENDER_OVERLAY *) mfc_render_handle;


	if (pMFC_RENDER_OVERLAY->which == 1) {
		pDDSOverlay = pMFC_RENDER_OVERLAY->pDD;
	}
	else if (pMFC_RENDER_OVERLAY->which == 0) {
		pDDSOverlay = pMFC_RENDER_OVERLAY->pDD_back;
	}


	memset(&ddsd, 0, sizeof(ddsd));
	ddsd.dwSize = sizeof(ddsd);

	// Lock down the surface so we can modify it's contents.
	hRet = pDDSOverlay->Lock( NULL, &ddsd, DDLOCK_WAITNOTBUSY, NULL);
	if (hRet != DD_OK) {
		PRINT_ERRMSG(TEXT("Unable to show overlay surface!"));
		return;
	}

	pSurf = (LPBYTE)ddsd.lpSurface;

	y_size = width * height;
	u_size = y_size >> 2;


	switch (pMFC_RENDER_OVERLAY->surface_type) {
	case MFC_RENDER_SURFACE_TYPE_YV12:	// YV12의 경우는 그대로 복사한다.
		if (img_type == MFC_RENDER_IMAGE_TYPE_YUV420) {
			memcpy(pSurf, pImg, y_size);
			memcpy(pSurf + y_size, pImg + y_size + u_size, u_size);
			memcpy(pSurf + y_size + u_size, pImg + y_size, u_size);
		}
		else if (img_type == MFC_RENDER_IMAGE_TYPE_YV12) {
			memcpy(pSurf, pImg, y_size + (u_size << 1));
		}
		else if (img_type == MFC_RENDER_IMAGE_TYPE_RGB565) {
			PRINT_ERRMSG(TEXT("This case is not supported. : (Surface type is YV12 and Image type is RGB565)"));
		}
		break;

	case MFC_RENDER_SURFACE_TYPE_RGB565:	// RGB565의 경우는 SW YUV->RGB 변환 수행
		if (img_type == MFC_RENDER_IMAGE_TYPE_YUV420) {
			_yuv420ToRgb565(pImg, pImg + y_size, pImg + y_size + u_size, width, height,
							pSurf, width, height,
							0);
		}
		else if (img_type == MFC_RENDER_IMAGE_TYPE_YV12) {
			_yuv420ToRgb565(pImg, pImg + y_size + u_size, pImg + y_size, width, height,
							pSurf, width, height,
							0);
		}
		else if (img_type == MFC_RENDER_IMAGE_TYPE_RGB565) {
			memcpy(pSurf, pImg, y_size << 1);
		}
		break;

	default:
		break;
	}

    pDDSOverlay->Unlock(NULL);

}
开发者ID:HITEG,项目名称:TenByTen6410_SLC,代码行数:99,代码来源:mfc_render.cpp

示例14: RenderSmallFontString

static int RenderSmallFontString(char *textPtr,int sx,int sy,int alpha, int red, int green, int blue)
{
	DDSURFACEDESC ddsdimage;
   	unsigned short *destPtr;
	unsigned short *srcPtr;
	int extra = 0;
	int alphaR = MUL_FIXED(alpha,red);
	int alphaG = MUL_FIXED(alpha,green);
	int alphaB = MUL_FIXED(alpha,blue);

	AVPMENUGFX *gfxPtr;
	LPDIRECTDRAWSURFACE surface;

	gfxPtr = &AvPMenuGfxStorage[AVPMENUGFX_SMALL_FONT];
	surface = gfxPtr->ImagePtr;

	memset(&ddsdimage, 0, sizeof(ddsdimage));
	ddsdimage.dwSize = sizeof(ddsdimage);

	/* lock the image */
	while (surface->Lock(NULL, &ddsdimage, DDLOCK_WAIT, NULL) == DDERR_WASSTILLDRAWING);


	while( *textPtr )
	{
		char c = *textPtr++;

		if (c>=' ')
		{
			int topLeftU = 1+((c-32)&15)*16;
			int topLeftV = 1+((c-32)>>4)*16;

			srcPtr = (unsigned short *)(ddsdimage.lpSurface) + (topLeftU)+(topLeftV*ddsdimage.lPitch/2);
			
			int x,y;

			for (y=sy; y<HUD_FONT_HEIGHT+sy; y++)
			{
				destPtr = (unsigned short *)(ScreenBuffer + sx*2 + y*BackBufferPitch);

				for (x=0; x<HUD_FONT_WIDTH; x++)
				{
					if (*srcPtr)
					{
						unsigned int srcR,srcG,srcB;
						unsigned int destR,destG,destB;

						destR = (int)(*destPtr) & DisplayPixelFormat.dwRBitMask;
						destG = (int)(*destPtr) & DisplayPixelFormat.dwGBitMask;
						destB = (int)(*destPtr) & DisplayPixelFormat.dwBBitMask;

						srcR = (int)(*srcPtr) & DisplayPixelFormat.dwRBitMask;
						srcG = (int)(*srcPtr) & DisplayPixelFormat.dwGBitMask;
						srcB = (int)(*srcPtr) & DisplayPixelFormat.dwBBitMask;

						destR += MUL_FIXED(alphaR,srcR);
						if (destR>DisplayPixelFormat.dwRBitMask) destR = DisplayPixelFormat.dwRBitMask;
						else destR &= DisplayPixelFormat.dwRBitMask;

						destG += MUL_FIXED(alphaG,srcG);
						if (destG>DisplayPixelFormat.dwGBitMask) destG = DisplayPixelFormat.dwGBitMask;
						else destG &= DisplayPixelFormat.dwGBitMask;

						destB += MUL_FIXED(alphaB,srcB);
						if (destB>DisplayPixelFormat.dwBBitMask) destB = DisplayPixelFormat.dwBBitMask;
						else destB &= DisplayPixelFormat.dwBBitMask;

						*destPtr = (short)(destR|destG|destB);
					}
					destPtr++;
					srcPtr++;
				}
				srcPtr += (ddsdimage.lPitch/2) - HUD_FONT_WIDTH; 
			}
			sx += AAFontWidths[c];
			#if 0
			if(c!=32)
			{
				extra += 8-AAFontWidths[c];
			}
			else
			{
				sx+=extra+8-AAFontWidths[c];
				extra=0;
			}
			#endif
		}
	}
开发者ID:videogamepreservation,项目名称:avp,代码行数:88,代码来源:AvP_MenuGfx.cpp

示例15: pProjCh

void
IndexedFont_Kerned :: RenderString_Unclipped
(
	struct r2pos& R2Pos_Cursor,
	int FixP_Alpha,
	const SCString& SCStr
) const
#if 1
{
	ProjChar* pProjChar_I = SCStr . pProjCh();

	const LPDIRECTDRAWSURFACE image_ptr = GetImagePtr();

	DDSURFACEDESC ddsdimage;
	
	memset(&ddsdimage, 0, sizeof(ddsdimage));
	ddsdimage.dwSize = sizeof(ddsdimage);

	/* lock the image */
	while (image_ptr->Lock(NULL, &ddsdimage, DDLOCK_WAIT, NULL) == DDERR_WASSTILLDRAWING);

	while ( *pProjChar_I )
	{
		const ProjChar ProjCh = *pProjChar_I;

		if
		(
			bCanRender( ProjCh )
		)
		{
			#if 0
			textprint("printable \'%c\'\n",ProjCh);
			#endif

			#if 0
			RenderChar_Clipped
			(
				R2Pos_Cursor,
				R2Rect_Clip,
				FixP_Alpha,
				ProjCh
			);
			#else
			if (ProjCh != ' ')
			{
				unsigned int theOffset=ProjCh - 32;
				int width = GetWidth(ProjCh);

				/*
				if
				(
					GetOffset
					(
						theOffset,
						ProjCh
					)
				)
				*/
				{
					if
					(
						width>0
					)
					{
						{
							// This code adapted from DrawGraphicWithAlphaChannel();
							// it assumes you're in a 16-bit mode...

							// okay, now we have the surfaces, we can copy from one to the other,
							// darkening pixels as we go
							{
								long fontimagePitchInShorts = (ddsdimage.lPitch/2); 
								long backbufferPitchInShorts = (BackBufferPitch/2); 

								unsigned short* fontimageRowStartPtr =
								(
									((unsigned short *)ddsdimage.lpSurface)
									+
									(GetHeight()*theOffset*fontimagePitchInShorts)
								);

								unsigned short* backbufferRowStartPtr =
								(
									((unsigned short *)ScreenBuffer)
									+
									(R2Pos_Cursor.y*backbufferPitchInShorts)
									+
									(R2Pos_Cursor.x)
								);
								int screenY = R2Pos_Cursor.y;

								for (int yCount=GetHeight(); yCount>0; yCount--)
								{
									unsigned short* fontimagePtr = fontimageRowStartPtr;
									unsigned short* backbufferPtr = backbufferRowStartPtr;

									int xIndex = R2Pos_Cursor.x+CloakingPhase/64;
									int yIndex = (screenY+CloakingPhase/128)&127;

//									if (screenY >= R2Rect_Clip.y0 && screenY <= R2Rect_Clip.y1)
//.........这里部分代码省略.........
开发者ID:OpenSourcedGames,项目名称:Aliens-vs-Predator,代码行数:101,代码来源:indexfnt.cpp


注:本文中的LPDIRECTDRAWSURFACE::Lock方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。