reactos操作系统实现(198)
来源:互联网 发布:java动态代理有什么用 编辑:程序博客网 时间:2024/06/08 14:10
为了测试2位颜色位图装载到设备是否出错,编写了下面这段测试代码,如下:
#001 /* test with 2 bits color depth, not likelyto succeed */
#002 hbmp = CreateBitmap(16, 16, 1, 2, bits);
#003 ok( hbmp != NULL, "CreateBitmapreturns %p/n", hbmp);
#004 oldhbmp = SelectObject( hdcmem, hbmp);
#005 if( bitspixel != 2)
#006 ok( !oldhbmp, "SelectObject of abitmap with 2 bits/pixel should return NULL/n");
从这段代码可以看到,当内存DC不是两位颜色时,选择加载2位颜色的位图,就需要返回空句柄,否则就是这个SelectObject的API函数实现有问题。在没有修改这个BUG之前,这个函数返回是成功的加载位图了。因此需要修改这个函数的代码如下:
#001 HBITMAP
#002 APIENTRY
#003 NtGdiSelectBitmap(
#004 INHDC hDC,
#005 INHBITMAP hBmp)
#006 {
#007 PDC pDC;
#008 PDC_ATTR pdcattr;
#009 HBITMAP hOrgBmp;
#010 PSURFACE psurfBmp, psurfOld;
#011 HRGN hVisRgn;
#012
#013 if (hDC == NULL || hBmp == NULL) returnNULL;
#014
#015 pDC = DC_LockDc(hDC);
#016 if(!pDC)
#017 {
#018 return NULL;
#019 }
#020 pdcattr = pDC->pdcattr;
#021
#022 /* must be memory dc to select bitmap */
#023 if (pDC->dctype != DC_TYPE_MEMORY)
#024 {
#025 DC_UnlockDc(pDC);
#026 return NULL;
#027 }
#028
#029 psurfBmp = SURFACE_LockSurface(hBmp);
#030 if (!psurfBmp)
#031 {
#032 DC_UnlockDc(pDC);
#033 return NULL;
#034 }
#035
#036 //判断位图颜色数目是否与设备的颜色数目一样。
#037 if(pDC->ppdev)
#038 {
#039 if(BitsPerFormat(psurfBmp->SurfObj.iBitmapFormat) == 4)
#040 {
#041 //
#042 DPRINT1("BitsPerFormat%d/n",BitsPerFormat(psurfBmp->SurfObj.iBitmapFormat));
#043 DPRINT1("pDC->ppdev->gdiinfo.cBitsPixel%d/n",pDC->ppdev->gdiinfo.cBitsPixel);
#044
#045 if (BitsPerFormat(psurfBmp->SurfObj.iBitmapFormat) !=
#046 pDC->ppdev->gdiinfo.cBitsPixel)
#047 {
#048 SURFACE_UnlockSurface(psurfBmp);
#049
#050 DC_UnlockDc(pDC);
#051 returnNULL;
#052 }
#053 }
#054 }
#055
从36行代码开始,就是添加来解决这个BUG的,最后运行测试代码,成功地返回NULL句柄。
- reactos操作系统实现(198)
- reactos操作系统实现(1)
- reactos操作系统实现(2)
- reactos操作系统实现(3)
- reactos操作系统实现(4)
- reactos操作系统实现(5)
- reactos操作系统实现(6)
- reactos操作系统实现(7)
- reactos操作系统实现(8)
- reactos操作系统实现(9)
- reactos操作系统实现(10)
- reactos操作系统实现(11)
- reactos操作系统实现(12)
- reactos操作系统实现(13)
- reactos操作系统实现(14)
- reactos操作系统实现(15)
- reactos操作系统实现(16)
- reactos操作系统实现(17)
- C# 控制台程序下,如何启用Timer 及多次调用后如何更改周期
- 如何培养你的气质
- 成都行(二)
- JASO
- 面试新工作的感悟
- reactos操作系统实现(198)
- MYSQL学习
- PuTTY + Xming, using gedit command under windows.
- http://feihuayikuang.blog.sohu.com/139047736.html
- 增值税/所得税 概念与区别
- 2010春节期间易语言论坛大事记,5.0/静态编译/黑月/白月/驱动/加密壳
- 在word中如何全部取消超链接
- C#使用Timer 执行后台任务
- 16天学会Java (很不错的文章,推荐)