/ *
HDC HDC, printer DC
Hbitmap HBMP, to be tapped
INT IX, bitmap of the upper corner X coordinate
INT IY, bitmap of the upper left corner y coordinate
Double DScalex, printer resolution, and the ratio of the screen resolution X direction, in the case where the height and width is not specified.
Double DScaley, printer resolution and ratio of the screen resolution y direction, on the time without pointing the level and width
INT iWidth = 0, display width of bitmap
INT iLENGTH = 0 bitmap display height
* /
Void Draw (HDC HDC, Hbitmap HBMP, IX, INT IY, Double DScalex = 1.0, Double DScaley = 1.0, Int iWidth = 0, Idenngth = 0)
{
HPALETTE HPAL;
Bitmap BM;
BitmapInfoheader Bi;
LpbitmapInfoHeader LPBI;
DWORD DWLEN;
Handle HDIB;
Handle Handle;
HDC HDC1;
IF (GetDeviceCaps (HDC, RasterCaps) & rc_palette
{
UINT nsize = sizeof (logpalette) (SIZEOF (PALETTEENTRY) * 256);
Logpalette * PLP = (logpalette *) New byte [nsize];
PLP-> paversion = 0x300;
PLP-> PALNUMENTRIES = GetSystemPaletteentries (HDC, 0, 255, PLP-> PALPALENTRY);
HPAL = CREATEPALETTE (PLP);
DELETE [] PLP;
}
IF (hpal == null) HPAL = (HPALETTE) GetStockObject (default_palette);
:: GetObject (HBMP, SIZEOF (BM), (LPSTR) & BM);
bi.bisize = sizeof (bitmapinfohead);
Bi.biwidth = bm.bmwidth;
Bi.biheight = bm.bmheight;
Bi.Biplanes = 1;
Bi.BIBITCOUNT = BM.BMPLANES * BM.BMBITSPIXEL Download Adobe Reader
Bi.Bicompression = BI_RGB;
Bi.bisizeImage = 0;
bi.bixpelspermeter = 0;
Bi.biypelspermeter = 0;
Bi.bi.biRused = 0;
Bi.Biclrimportant = 0;
INT ncolors = (1 << bi.biBitcount); if (ncolors> 256)
ncolors = 0;
Dwlen = bi.bisize ncolors * sizeof (rgbquad);
HDC1 = :: getDC (null);
HPAL = SELECTPALETTE (HDC1, HPAL, FALSE);
RealizePalette (HDC1);
HDIB = GLOBALLOC (GMEM_FIXED, DWLEN);
IF (! HDIB)
{
SelectPalette (HDC1, HPAL, FALSE);
:: ReleaseDC (NULL, HDC1);
DeleteObject (HPAL);
Return;
}
LPBI = (lpbitmapinfoheader) HDIB;
* lpbi = bi;
:: GetDibits (HDC1, HBMP, 0L, (DWORD) BI.BIHEIGHT,
(Lpbyte) NULL, (LPBITMAPINFO) LPBI, (DWORD) DIB_RGB_COLORS;
Bi = * lpbi;
IF (bi.bisizeImage == 0)
Bi.bisizeImage = (((bi.biwidth * bi.biBitcount 31) & ~ 31) / 8) * bi.biheight;
DWLEN = bi.bisizeImage;
IF (Handle = GlobalRealloc (HDIB, DWLEN, GMEM_MOVEABLE))
HDIB = Handle;
Else
{
GlobalFree (HDIB);
SelectPalette (HDC1, HPAL, FALSE);
:: ReleaseDC (NULL, HDC1);
DeleteObject (HPAL);
Return;
}
LPBI = (lpbitmapinfoheader) HDIB;
Bool bgotbits = getDibits (HDC1, HBMP, 0L, (DWORD) BI.BIHEIGHT, (LPBYTE) LPBI (Bi.bisize NCOLORS * SIZEOF (RGBQUAD),
(Lpbitmapinfo) lpbi, (dword) DIB_RGB_COLORS;
IF (! bgotbits)
{
GlobalFree (HDIB);
SelectPalette (HDC1, HPAL, FALSE);
:: ReleaseDC (NULL, HDC1);
DeleteObject (HPAL);
Return;
}
IF (iWidth == 0 || ilength == 0)
{
iWidth = lpbi-> biwidth;
Ilength = lpbi-> biheight;
iWidth = (int);
ilength = (int);
}
Stretchdibits (HDC, IX, IY, IWIDTH, ILENGTH, 0, 0, LPBI-> BIWIDTH, LPBI-> BIHEIGHT, (LPBYTE) LPBI // Address for Bitmap Bits
(Bi.bisize NCOLORS * SIZEOF (RGBQUAD)), (LPBitmapInfo) LPBI, DIB_RGB_COLORS, SRCCOPY
SelectPalette (HDC1, HPAL, FALSE);
:: ReleaseDC (NULL, HDC1);
DeleteObject (HDIB); deleteObject (HPAL);
}
// Attachment: Get a DC bitmap code
Hbitmap Getsrcbit (HDC HDC, DWORD BITWIDTH, DWORD BITHEIGHT)
{
HDC HBUFDC;
Hbitmap Hbitmap, HbitTemp;
HBUFDC = CREATECOMPATIBLEDC (HDC);
Hbitmap = CreateCompaPaTMap (HDC, Bitwidth, BitHeight);
HbitTemp = (hbitmap) SelectObject (HBUFDC, HBitmap);
Stretchblt (HbufDC, 0, 0, Bitwidth, Bitheight,
HDC, 0, 0, Bitwidth, BitHHEight, Srccopy;
Hbitmap = (hbitmap) SelectObject (HBUFDC, HbitTemp);
:: Deletedc (HBUFDC);
Return hbitmap;
}