3631|8

75

帖子

0

TA的资源

一粒金砂(初级)

楼主
 

有关WINCE下图片显示的问题 [复制链接]

我使用IIMAGE去显示一个图片,发现不管多大的图片都会平铺到屏幕上,不知道这是什么问题引起的?怎么能解决?下面是部分代码,我怀疑是这一部分的代码:
//描画图片到内存中
void vDrawImage()
{
        HRESULT hResult;
        BOOL        bResult;
        RECT        stDisplayRect,stClientRect;
        ImageInfo        stImageInfo;                //图片显示信息
        HBITMAP                hBitmap;
        IBitmapImage*   pBitmap;
        HDC                        hdc;
        UINT                width,height;



        hdc = GetDC(hWnd);                //获取当前window默认的HDC


        bResult = GetClientRect(hWnd,&stClientRect);
        if( NULL == bResult )
                vPrintfError();
#if 1
        width = stClientRect.right - stClientRect.left ;
        height = stClientRect.bottom - stClientRect.top;
#else
        width = 0 ;
        height = 0;
#endif
        m_pImagingFactory-> CreateBitmapFromImage(m_pImage,   
                                                                                width,   
                                                                                height,   PixelFormat24bppRGB,   InterpolationHintDefault,   &pBitmap);
        pBitmap->QueryInterface(IID_IImage,   (void   **)&m_pImage);   

        hResult = m_pImage->GetImageInfo(&stImageInfo);
        if( S_OK != hResult)
                vPrintfError();

        //确定显示区域
        stDisplayRect.left = 0 ;
        stDisplayRect.top = 0 ;
        stDisplayRect.right = stImageInfo.Width ;
        stDisplayRect.bottom  = stImageInfo.Height ;

       
        hBitmap = CreateCompatibleBitmap(hdc,stImageInfo.Width,stImageInfo.Height);
        if(NULL == hBitmap )
                vPrintfError();

    hDcMem = CreateCompatibleDC(hdc);
        if(NULL == hDcMem )
                vPrintfError();

    SelectObject(hDcMem,hBitmap);
       
       
        hResult = m_pImage->Draw(hDcMem,&stDisplayRect,NULL);
        if( S_OK != hResult)
                vPrintfError();
        return;
       
}

最新回复

pBitmap->Release();  详情 回复 发表于 2009-8-28 11:29
点赞 关注

回复
举报

78

帖子

0

TA的资源

一粒金砂(初级)

沙发
 
经过进一步调查,为什么我的Imageinfo 拿出来的都是全屏的宽度和高度,例如:我要显示一个52×52的jpg,怎么取出来的image信息是屏幕的宽度和高度呢?
 
 

回复

66

帖子

0

TA的资源

一粒金砂(初级)

板凳
 
说明之前的代码有问题
 
 
 

回复

80

帖子

0

TA的资源

一粒金砂(初级)

4
 
MARK!
事情做不出来,好郁闷来喝点水!
老板说什么都容易啊!就是苦了我们做技术的,我们吹不得牛,我们0就是0,1就是1。没有积累与经验谈什么都是空的!
 
 
 

回复

79

帖子

0

TA的资源

一粒金砂(初级)

5
 
TO Reallyu:
说明之前的代码有问题是什么意思? 请明示。
 
 
 

回复

81

帖子

0

TA的资源

一粒金砂(初级)

6
 
我准备这样做不知道可以不,如果图片尺寸大于目前屏幕的尺寸时,根据图片的宽高比进行适应屏幕。不知道这样可以不?
 
 
 

回复

66

帖子

0

TA的资源

一粒金砂(初级)

7
 
GetClientRect(hWnd,&stClientRect);
你得到的就是屏幕大小的RECT
m_pImagingFactory-> CreateBitmapFromImage(m_pImage,  
width,  
height,  PixelFormat24bppRGB,  InterpolationHintDefault,  &pBitmap);
这里的WIDTH和HEIGHT就是屏幕大小,你建立的BITMAP的大小就是屏幕大小了。
hResult = m_pImage->GetImageInfo(&stImageInfo);
得到的IMAGE大小也就屏幕大小了。
hBitmap = CreateCompatibleBitmap(hdc,stImageInfo.Width,stImageInfo.Height);
创建的BITMAP也是屏幕大小
那显示的大小就是屏幕到小了。
CreateBitmapFromImage()你这个参数大小改成m_pImagingFactory-> CreateBitmapFromImage(m_pImage,  
0,  
0,  PixelFormat24bppRGB,  InterpolationHintDefault,  &pBitmap);
这个是CreateBitmapFromImage()宽和高的说明
width
[in] A UINT value that specifies the width, in pixels, of the new bitmap image.
Set this value to 0 create a new bitmap image that is the same height as the source image.

height
[in] A UINT value that specifies the height, in pixels, of the new bitmap image.
Set this value to 0 create a new bitmap image that is the same width as the source image.

 
 
 

回复

72

帖子

0

TA的资源

一粒金砂(初级)

8
 
楼上说的很清楚了!
 
 
 

回复

76

帖子

0

TA的资源

一粒金砂(初级)

9
 
pBitmap->Release();
 
 
 

回复
您需要登录后才可以回帖 登录 | 注册

随便看看
查找数据手册?

EEWorld Datasheet 技术支持

相关文章 更多>>
关闭
站长推荐上一条 1/10 下一条
福禄克有奖直播:高精度测温赋能电子制造 报名中!
直播时间:2025年2月28日(周五)上午10:00
直播主题:高精度测温赋能电子制造
小伙伴们儿快来报名直播吧~好礼等你拿!

查看 »

 
EEWorld订阅号

 
EEWorld服务号

 
汽车开发圈

About Us 关于我们 客户服务 联系方式 器件索引 网站地图 最新更新 手机版

站点相关: 国产芯 安防电子 汽车电子 手机便携 工业控制 家用电子 医疗电子 测试测量 网络通信 物联网

北京市海淀区中关村大街18号B座15层1530室 电话:(010)82350740 邮编:100190

电子工程世界版权所有 京B2-20211791 京ICP备10001474号-1 电信业务审批[2006]字第258号函 京公网安备 11010802033920号 Copyright © 2005-2025 EEWORLD.com.cn, Inc. All rights reserved
快速回复 返回顶部 返回列表