bool Image::Draw(HDC hdc,int x,int y,int cx,int cy){ if(_image==0) return 0; Gdiplus::Graphics gph(hdc); if(cx==0) cx = ((_Image*)_image)->GetWidth(); if(cy==0) cy = ((_Image*)_image)->GetHeight(); Gdiplus::Point pt[3] = {Gdiplus::Point(x,y),Gdiplus::Point(x+cx,x),Gdiplus::Point(y,cy+y)}; return gph.DrawImage((_Image*)_image,pt,3)==0; }
void ImageDelegate::Draw(HDC dc) { Graphics gph(dc) ; gph.DrawImage( &m_image, Rect(m_bound.left, m_bound.top, m_bound.right - m_bound.left, m_bound.bottom - m_bound.top), 0, 0, m_image.GetWidth(), m_image.GetHeight(), UnitPixel, NULL ) ; }
HBITMAP Image::GetBitmap(){ if(_image==0) return 0; _Image* img = ((_Image*)_image); int cx = img->GetWidth(); if(cx==0) return 0; int cy = img->GetHeight(); if(cy==0) return 0; DC dc; dc.GetDC(); HBITMAP bmp = CreateBitmap(dc,cx,cy); if(bmp==0){ PrintLastErrorD(L"Image::GetBitmap: %s"); return 0; } HDC hdc = ::CreateCompatibleDC(dc); dc.ReleaseDC(); HGDIOBJ old = ::SelectObject(hdc,bmp); Gdiplus::Graphics gph(hdc); Gdiplus::Point pt[3] = {Gdiplus::Point(0,0),Gdiplus::Point(cx,0),Gdiplus::Point(0,cy)}; gph.DrawImage((_Image*)_image,pt,3); bmp = (HBITMAP)::SelectObject(hdc,old); ::DeleteDC(hdc); return bmp; }