mfc中Destroy CImage产生错误 m_hDC == 0

使用了GetDC,就需要ReleaseDC();

 

HBITMAP hbmp = (HBITMAP)tempbitmap.Detach();

 

以下暂存

//        int size = hbmp.bmWidth * hbmp.bmWidthBytes;
//        unsigned char * pBits = (unsigned char *)malloc(size);
//        GetBitmapBits(hbmp,size,pBits);
        HBITMAP hBitmapDst;
        hBitmapDst = (HBITMAP)m_dibM.DDBToDIB((HBITMAP)hbmp,BI_RGB, NULL);
        if( hBitmapDst )
        {
            (void)m_dibM.WriteDIB("temp.bmp", hBitmapDst,rcCrop);
        }

        CImage imgDst;
        imgDst.Load("temp.bmp");
        

        if(!imgTemp.IsNull())
        {
            imgTemp.Destroy();
        }
//        imgTemp.Load("temp.bmp");
        ImageCopy(imgDst,imgTemp,rcCrop);
        imgTemp.Save("temp2.bmp");
        m_img.Create(imgTemp.GetWidth(),imgTemp.GetHeight(),32);
//        imageTemp.Save("test.jpg");
//        m_img.SetStretchBltMode(HALFTONE);
//        imageTemp.StretchBlt(m_img.GetDC(),0,0,rect.right,rect.bottom,rect.right,rect.bottom,-rect.right,-rect.bottom);

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
下面这段代码有什么问题 CKSTime gKSTime; pthread_mutex_t m_lock; CKSTime * CKSTime::GetCurrentTime() { static unsigned long lasttick=0; pthread_mutex_lock(&m_lock); unsigned long tick = ::GetTickCount(); if (lasttick==0) lasttick=tick; if (tick==m_LastTick) { pthread_mutex_unlock(&m_lock); return(this); } if (tick>m_LastTick && (tick-lasttick)<10000) { int dtick = tick-m_LastTick+m_MSecond; m_LastTick = tick; m_MSecond = dtick%1000; dtick = dtick/1000+m_Second; m_Second = dtick%60; dtick = dtick/60+m_Minute; m_Minute = dtick%60; dtick = dtick/60+m_Hour; if (dtick<24) { m_Hour = dtick; pthread_mutex_unlock(&m_lock); return(this); } } lasttick=tick; ReflushTime(); pthread_mutex_unlock(&m_lock); return(this); } CKSTime *GetKSTime(void) { return gKSTime.GetCurrentTime(); } CKSTime::CKSTime() { pthread_mutex_init(&m_lock,NULL); pthread_mutex_lock(&m_lock); ReflushTime(); pthread_mutex_unlock(&m_lock); } CKSTime::~CKSTime() { pthread_mutex_destroy(&m_lock); } void CKSTime::ReflushTime() { pthread_mutex_lock(&m_lock); struct tm klgLocalTime; time_t now; time(&now); memcpy(&klgLocalTime, localtime(&now), sizeof(klgLocalTime)); m_LastTick = ::GetTickCount(); m_Year = klgLocalTime.tm_year + 1900 ; m_Month = klgLocalTime.tm_mon + 1 ; m_Day = klgLocalTime.tm_mday; m_WeekDay = klgLocalTime.tm_wday; m_Hour = klgLocalTime.tm_hour; m_Minute = klgLocalTime.tm_min; m_Second = klgLocalTime.tm_sec; m_MSecond = m_LastTick%1000; pthread_mutex_unlock(&m_lock); } void CKSTime::ReflushTime2(void) { pthread_mutex_lock(&m_lock); ReflushTime(); pthread_mutex_unlock(&m_lock); }
最新发布
07-13

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值