Patch level : 2.o nopatch

Files correlati     : xvaga.dll
Ricompilazione Demo : [ ]
Commento            :

Migliorata stampa immagini grandi su Win 98


git-svn-id: svn://10.65.10.50/trunk@11601 c028cbd2-c16b-5b4b-a496-9718f37d4682
This commit is contained in:
guy 2003-11-18 09:18:36 +00:00
parent cfbff9b347
commit 808f9f7ff3
3 changed files with 27 additions and 22 deletions

View File

@ -204,9 +204,7 @@ void OsWin32_UpdateWindow(unsigned int handle)
// Drawing bitmaps
///////////////////////////////////////////////////////////
bool OsWin32_DrawBitmap(const wxBitmap& bmp, wxDC& dc,
int xd, int yd, int wd, int hd,
int xs, int ys, int ws, int hs)
bool OsWin32_DrawBitmap(const wxBitmap& bmp, wxDC& dc, const wxRect& dst, const wxRect& src)
{
HBITMAP hBMP = (HBITMAP)bmp.GetHBITMAP();
bool ok = hBMP != NULL;
@ -228,9 +226,8 @@ bool OsWin32_DrawBitmap(const wxBitmap& bmp, wxDC& dc,
if (ok)
{
LPBYTE bits = new BYTE[bih.biSizeImage];
::GetDIBits(hMemDC, hBMP, 0, hs,
bits, bi, DIB_RGB_COLORS);
::StretchDIBits((HDC)dc.GetHDC(), xd, yd, wd, hd, xs, 0, ws, hs,
::GetDIBits(hMemDC, hBMP, 0, src.height, bits, bi, DIB_RGB_COLORS);
::StretchDIBits(hDC, dst.x, dst.y, dst.width, dst.height, src.x, src.y, src.width, src.height,
bits, bi, DIB_RGB_COLORS, SRCCOPY);
delete bits;
}
@ -239,8 +236,9 @@ bool OsWin32_DrawBitmap(const wxBitmap& bmp, wxDC& dc,
else
{
HGDIOBJ hOldBitmap = ::SelectObject(hMemDC, hBMP);
::SetStretchBltMode((HDC)hDC, STRETCH_DELETESCANS);
::StretchBlt((HDC)hDC, xd, yd, wd, hd, hMemDC, xs, ys, ws, hs, SRCCOPY);
::SetStretchBltMode(hDC, COLORONCOLOR);
::StretchBlt(hDC, dst.x, dst.y, dst.width, dst.height,
hMemDC, src.x, src.y, src.width, src.height, SRCCOPY);
::SelectObject(hMemDC, hOldBitmap);
}
::DeleteDC(hMemDC);

View File

@ -2,8 +2,7 @@ void OsWin32_Beep(int severity);
bool OsWin32_CheckPrinterInfo(const void* data, unsigned int size);
void* OsWin32_ConvertFromNativePrinterInfo(void* hGlobal, unsigned int& nSize);
void* OsWin32_ConvertToNativePrinterInfo(void* data, unsigned int nSize);
bool OsWin32_DrawBitmap(const wxBitmap& bmp, wxDC& dc,
int xd, int yd, int wd, int hd, int xs, int ys, int ws, int hs);
bool OsWin32_DrawBitmap(const wxBitmap& bmp, wxDC& dc, const wxRect& dst, const wxRect& src);
void OsWin32_DrawDottedRect(unsigned int hDC, int left, int top, int right, int bottom);
wxString OsWin32_File2App(const char* filename);

View File

@ -2025,6 +2025,15 @@ void xvt_dwin_draw_icon(WINDOW win, int x, int y, int rid)
}
}
wxRect ComputeRect(const wxRect& rct, int h, int v, int k)
{
const int sx = rct.x + h * rct.width / k;
const int ex = rct.x + (h+1) * rct.width / k;
const int sy = rct.y + v * rct.height / k;
const int ey = rct.y + (v+1) * rct.height / k;
return wxRect(sx, sy, ex-sx, ey-sy);
}
void xvt_dwin_draw_image(WINDOW win, XVT_IMAGE image, RCT* dest, RCT* source)
{
XVT_ASSERT(image != NULL);
@ -2035,32 +2044,31 @@ void xvt_dwin_draw_image(WINDOW win, XVT_IMAGE image, RCT* dest, RCT* source)
const wxRect src = NormalizeRCT(source);
const wxRect dst = NormalizeRCT(dest);
const wxBitmap& bmp = ((TXVT_IMAGE*)image)->Bitmap();
if (src.GetPosition() == wxPoint(0,0) && src.GetSize() == dst.GetSize())
if (src.GetPosition() == wxPoint(0,0) && src.GetSize() == dst.GetSize() && bmp.Ok())
{
dc.DrawBitmap(bmp, dst.GetPosition());
}
else
{
#ifdef WIN32
if (!OsWin32_DrawBitmap(bmp, dc,
dst.x, dst.y, dst.width, dst.height,
src.x, src.y, src.width, src.height))
if (!OsWin32_DrawBitmap(bmp, dc, dst, src))
{
const int k = 4;
bool ok = false;
for (int s = k-1; s > 0 && !ok; s--)
for (int h = 0; h < k; h++)
{
wxImage img = ((TXVT_IMAGE*)image)->Image().GetSubImage(src);
img.Rescale(s * src.width / k, s * src.height / k);
ok = OsWin32_DrawBitmap(img.ConvertToBitmap(), dc,
dst.x, dst.y, dst.width, dst.height,
0, 0, s*src.width/k, s*src.height/k);
for (int v = 0; v < k; v++)
{
const wxRect destin = ComputeRect(dst, h, v, k);
wxRect source = ComputeRect(src, h, v, k);
wxImage img = ((TXVT_IMAGE*)image)->Image().GetSubImage(source);
source.x = source.y = 0;
OsWin32_DrawBitmap(img.ConvertToBitmap(), dc, destin, source);
}
}
}
#else
const wxImage& img = ((TXVT_IMAGE*)image)->Image());
wxImage sub = img.GetSubImage(src);
sub.Rescale(dst.width, dst.height);
dc.DrawBitmap(sub.ConvertToBitmap(), dst.GetPosition());
#endif