Patch level : 2.0 nopatch

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

Corretta stampa Bitmap molto grandi in Win98


git-svn-id: svn://10.65.10.50/trunk@11597 c028cbd2-c16b-5b4b-a496-9718f37d4682
This commit is contained in:
cris 2003-11-14 16:41:16 +00:00
parent 8170c4aa45
commit f7b99b82f3
3 changed files with 58 additions and 46 deletions

View File

@ -200,50 +200,52 @@ void OsWin32_UpdateWindow(unsigned int handle)
::UpdateWindow(hwnd);
}
void OsWin32_StretchBlt(unsigned int hDst, int xd, int yd, int wd, int hd,
unsigned int hSrc, int xs, int ys, int ws, int hs)
{
const int nColors = ::GetDeviceCaps((HDC)hDst, NUMCOLORS);
::SetStretchBltMode((HDC)hDst, nColors == 2 ? STRETCH_HALFTONE : STRETCH_DELETESCANS);
::StretchBlt((HDC)hDst, xd, yd, wd, hd, (HDC)hSrc, xs, ys, ws, hs, SRCCOPY);
}
///////////////////////////////////////////////////////////
// Drawing bitmaps
///////////////////////////////////////////////////////////
void OsWin32_DrawBitmap(unsigned int hBitmap, unsigned int hDC,
bool OsWin32_DrawBitmap(const wxBitmap& bmp, wxDC& dc,
int xd, int yd, int wd, int hd,
int xs, int ys, int ws, int hs)
{
const int nTechno = ::GetDeviceCaps((HDC)hDC, TECHNOLOGY);
if (nTechno == DT_RASPRINTER) // Sto stampando!
{
BITMAPINFO bi; memset(&bi, 0, sizeof(bi));
BITMAPINFOHEADER& bih = bi.bmiHeader;
bih.biSize = sizeof(bih);
HDC hMemDC = ::CreateCompatibleDC(NULL);
GetDIBits(hMemDC, (HBITMAP)hBitmap, 0, 0, NULL, &bi, DIB_RGB_COLORS);
if (bih.biSizeImage > 0)
{
LPBYTE bits = new BYTE[bih.biSizeImage];
::GetDIBits(hMemDC, (HBITMAP)hBitmap, 0, bih.biHeight,
bits, &bi, DIB_RGB_COLORS);
::StretchDIBits((HDC)hDC, xd, yd, wd, hd, xs, ys, ws, hs,
bits, &bi, DIB_RGB_COLORS, SRCCOPY);
delete bits;
}
::DeleteDC(hMemDC);
}
else
{
HDC hMemDC = ::CreateCompatibleDC((HDC)hDC);
HGDIOBJ hOldBitmap = ::SelectObject(hMemDC, (HBITMAP)hBitmap);
::SetStretchBltMode((HDC)hDC, STRETCH_DELETESCANS);
::StretchBlt((HDC)hDC, xd, yd, wd, hd, hMemDC, xs, ys, ws, hs, SRCCOPY);
::SelectObject(hMemDC, hOldBitmap);
::DeleteDC(hMemDC);
}
HBITMAP hBMP = (HBITMAP)bmp.GetHBITMAP();
bool ok = hBMP != NULL;
if (ok)
{
HDC hDC = (HDC)dc.GetHDC();
HDC hMemDC = ::CreateCompatibleDC((HDC)NULL);
const int nTechno = ::GetDeviceCaps(hDC, TECHNOLOGY);
if (nTechno == DT_RASPRINTER) // Sto stampando!
{
BITMAPINFO* bi = (BITMAPINFO *) malloc( sizeof( BITMAPINFOHEADER ) + 256 * sizeof(RGBQUAD ) );
memset(bi, 0, sizeof( BITMAPINFOHEADER ) );
BITMAPINFOHEADER& bih = bi->bmiHeader;
bih.biSize = sizeof(bih);
GetDIBits(hMemDC, hBMP, 0, bmp.GetHeight(), NULL, bi, DIB_RGB_COLORS);
ok = bih.biSizeImage > 0;
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,
bits, bi, DIB_RGB_COLORS, SRCCOPY);
delete bits;
}
free(bi);
}
else
{
HGDIOBJ hOldBitmap = ::SelectObject(hMemDC, hBMP);
::SetStretchBltMode((HDC)hDC, STRETCH_DELETESCANS);
::StretchBlt((HDC)hDC, xd, yd, wd, hd, hMemDC, xs, ys, ws, hs, SRCCOPY);
::SelectObject(hMemDC, hOldBitmap);
}
::DeleteDC(hMemDC);
}
return ok;
}
void OsWin32_DrawDottedRect(unsigned int hDC, int left, int top, int right, int bottom)

View File

@ -2,7 +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);
void OsWin32_DrawBitmap(unsigned int hBitmap, unsigned int hDC,
bool OsWin32_DrawBitmap(const wxBitmap& bmp, wxDC& dc,
int xd, int yd, int wd, int hd, int xs, int ys, int ws, int hs);
void OsWin32_DrawDottedRect(unsigned int hDC, int left, int top, int right, int bottom);
@ -15,8 +15,6 @@ int OsWin32_EnumerateSizes(unsigned int hDC, const char* name, long* sizes, shor
void OsWin32_SetCaptionStyle(unsigned int handle, bool set);
void* OsWin32_GetPrinterInfo(int& size, const char* printer);
void OsWin32_SetClippingRect(unsigned int hDC, int x, int y, int w, int h);
void OsWin32_StretchBlt(unsigned int hDst, int xd, int yd, int wd, int hd,
unsigned int hSrc, int xs, int ys, int ws, int hs);
void OsWin32_PlaceProcessInWindow(unsigned int instance, const char* name, unsigned int parent);
void OsWin32_UpdateWindow(unsigned int handle);

View File

@ -2041,12 +2041,24 @@ void xvt_dwin_draw_image(WINDOW win, XVT_IMAGE image, RCT* dest, RCT* source)
}
else
{
#ifdef WIN32
OsWin32_DrawBitmap(bmp.GetHBITMAP(), dc.GetHDC(),
dst.x, dst.y, dst.width, dst.height,
src.x, src.y, src.width, src.height);
#ifdef WIN32
if (!OsWin32_DrawBitmap(bmp, dc,
dst.x, dst.y, dst.width, dst.height,
src.x, src.y, src.width, src.height))
{
const int k = 4;
bool ok = false;
for (int s = k-1; s > 0 && !ok; s--)
{
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);
}
}
#else
const wxImage& img = ((const TXVT_IMAGE*)image)->Image();
const wxImage& img = ((TXVT_IMAGE*)image)->Image());
wxImage sub = img.GetSubImage(src);
sub.Rescale(dst.width, dst.height);
@ -3673,7 +3685,7 @@ public:
wxThread::ExitCode TIconizeTaskThread::Entry()
{
Sleep(500);
Sleep(250);
if (__bChildRunning) // Il programma e' ancora attivo
{
wxFrame* frame = (wxFrame*)_task_win;