b2科目四模拟试题多少题驾考考爆了怎么补救
b2科目四模拟试题多少题 驾考考爆了怎么补救

setstretchbltmode_扫雷中stretchblt_stretchblt

电脑杂谈  发布时间:2017-01-16 22:04:40  来源:网络整理

stretchblt_setstretchbltmode_扫雷中stretchblt

在项目的使用过程中,用户偶尔会反映系统的打印功能不能正常使用了,打印出来的页面是空白的。stretchblt经过一翻调查之后,觉的问题很可能出在了StretchBlt上面,貌这个函数具有设备依赖性,并不会被所有的打印机驱动支持。随后将其换掉,采用与设备无关的StretchDIBits,大致代码如下:

//---------------------------------------------------------------

void *lpBits = 0;

int biSizeImage = bm.bmWidthBytes * bm.bmHeight;

lpBits = malloc( biSizeImage );

bitmap.GetBitmapBits( biSizeImage, lpBits );

BITMAPINFO BitmapInfo;

setstretchbltmode_stretchblt_扫雷中stretchblt

BitmapInfo.bmiHeader.biSize = sizeof( BITMAPINFOHEADER );

BitmapInfo.bmiHeader.biWidth = bm.bmWidth;

BitmapInfo.bmiHeader.biHeight = -bm.bmHeight;

BitmapInfo.bmiHeader.biPlanes = 1;

BitmapInfo.bmiHeader.biBitCount = 32;

BitmapInfo.bmiHeader.biCompression = BI_RGB;

BitmapInfo.bmiHeader.biClrUsed = 0;

BitmapInfo.bmiHeader.biSizeImage = 0;

BitmapInfo.bmiHeader.biXPelsPerMeter = 0;

BitmapInfo.bmiHeader.biYPelsPerMeter = 0;

BitmapInfo.bmiHeader.biClrImportant = 0;

StretchDIBits( *pDC, iOffset_X, iOffset_Y, iBitMap_X, iBitMap_Y, 0, 0, bm.bmWidth, bm.bmHeight, lpBits, &BitmapInfo, DIB_RGB_COLORS, SRCCOPY );

//------------------------------------------------------------------

其中要注意的地方:

1) biSizeImage的大小获取是bm.bmWidthBytes * bm.bmHeight;而不是bm.bmWidth*bm.bmHeight。stretchblt

2)BitmapInfo.bmiHeader.biHeight = -bm.bmHeight;注意是负,如果赋正的话打印内容会完全反过来。


本文来自电脑杂谈,转载请注明本文网址:
http://www.pc-fly.com/a/jisuanjixue/article-26778-1.html

    相关阅读
      发表评论  请自觉遵守互联网相关的政策法规,严禁发布、暴力、反动的言论

      热点图片
      拼命载入中...