U
user
Hi all...
i am trying to print an image using GDI - but the only thing i get is a
black rectangle.
Does anybody know what is wrong, or how else to get the bitmap on the
printer (GDI+ is not possible. it is a POS printer (for restaurants) and
the printer internal fonts are a MUST for printing speed. as far as i
know printer internal fonts are only accessable through GDI, so all my
printing is GDI up to now)
the relevant code pieces:
first of all i import StretchBlt from gdi32.dll
[DllImport( "gdi32", CharSet = CharSet.Auto )]
private static extern bool StretchBlt( IntPtr hdcDest, int
xDest, int yDest, int wDest, int hDest, IntPtr hdcSrc, int xSrc, int
ySrc, int wSrc, int hSrc, int RasterOperation );
within my class i define the CopyBitmap Method
public static int CopyBitmap( IntPtr HDC, int x, int y, int w,
System.Drawing.Image Image) {
int h = w * Image.Height / Image.Width;
StretchBlt( hDestDC, x, y, w, h, BitPtr, 0, 0, Image.Width,
Image.Height, SRCCOPY );
return h;
}
and from another class i use this method
Image notiz = ...// load the image
if( notiz != null ) {
int w = m_RightMargin;
line += Win32Util.CopyBitmap( hdc, 0, line, w, notiz );
notiz.Dispose();
notiz = null;
}
i am trying to print an image using GDI - but the only thing i get is a
black rectangle.
Does anybody know what is wrong, or how else to get the bitmap on the
printer (GDI+ is not possible. it is a POS printer (for restaurants) and
the printer internal fonts are a MUST for printing speed. as far as i
know printer internal fonts are only accessable through GDI, so all my
printing is GDI up to now)
the relevant code pieces:
first of all i import StretchBlt from gdi32.dll
[DllImport( "gdi32", CharSet = CharSet.Auto )]
private static extern bool StretchBlt( IntPtr hdcDest, int
xDest, int yDest, int wDest, int hDest, IntPtr hdcSrc, int xSrc, int
ySrc, int wSrc, int hSrc, int RasterOperation );
within my class i define the CopyBitmap Method
public static int CopyBitmap( IntPtr HDC, int x, int y, int w,
System.Drawing.Image Image) {
int h = w * Image.Height / Image.Width;
StretchBlt( hDestDC, x, y, w, h, BitPtr, 0, 0, Image.Width,
Image.Height, SRCCOPY );
return h;
}
and from another class i use this method
Image notiz = ...// load the image
if( notiz != null ) {
int w = m_RightMargin;
line += Win32Util.CopyBitmap( hdc, 0, line, w, notiz );
notiz.Dispose();
notiz = null;
}