Home
Top.Mail.Ru Yandeks.Metrika
Forum: "Main";
Current archive: 2002.01.08;
Download: [xml.tar.bz2];

Down

Problem with the size of the image when printing Find similar branches


Oleg Gashev   (2001-12-15 11:14) [0]

It is impossible to print Image with exact dimensions. It still doesn't print correctly.
I do so. Find Bitmapa dimensions in inch:
sx, sy: real; ABitmap: = Image1.Picture.Bitmap; sx: = ABitmap.Width / GetDeviceCaps (image1.canvas.handle, LOGPIXELSX); sy: = ABitmap.Height / GetDeviceCaps (image1.canvas.handle, LOGPIXELSY);

Now I find the dimensions in pixels on the printer for printing:
relwidth: = trunc (GetDeviceCaps (Printer.canvas.handle, LOGPIXELSX) * sx); relheight: = trunc (GetDeviceCaps (Printer.canvas.handle, LOGPIXELSY) * sy);

Print:
Printer.BeginDoc; DrawImage (Printer.Canvas, Rect (0, 0, relWidth, relHeight), ABitmap); Printer.EndDoc;

DrawImage:
procedure DrawImage (Canvas: TCanvas; DestRect: TRect; ABitmap: TBitmap); var Header, Bits: Pointer; HeaderSize: Cardinal; BitsSize: Cardinal; begin GetDIBSizes (ABitmap.Handle, HeaderSize, BitsSize); Header: = AllocMem (HeaderSize); Bits: = AllocMem (BitsSize); try GetDIB (ABitmap.Handle, ABitmap.Palette, Header ^, Bits ^); StretchDIBits (Canvas.Handle, DestRect.Left, DestRect.Top, DestRect.Right, DestRect.Bottom, 0, 0, ABitmap.Width, ABitmap.Height, Bits, TBitmapInfo (Header ^), DIB_RGB_COLORS, SRCC; finally FreeMem (Header, HeaderSize); FreeMem (Bits, BitsSize); end; end;

All this prints with the wrong size. Where is the mistake?

Regards, Oleg.



MrBeer   (2001-12-16 21:27) [1]

// Print bitmap X x Y millimeters size procedure PrintBM (B: TBitmap; x_mm, y_mm: double); var resx, resy: double; begin resx: = Printer.PageWidth / GetDeviceCaps (Printer.Handle, LOGPIXELSX); resy: = Printer.PageHeight / GetDeviceCaps (Printer.Handle, LOGPIXELSY); Printer.Canvas.StretchDraw (Rect (0,0, round (x_mm * resx), round (y_mm * resy)), B); end; // Print bitmap X x Y inch size procedure PrintBMInch (B: TBitmap; x_inch, y_inch: double); begin PrintBM (B, x_inch * 2.54, y_inch * 2.54); end;



MrBeer   (2001-12-16 21:40) [2]

procedure PrintSameSize (B: TBitmap); var scalex, scaley: double; begin scalex: = GetDeviceCaps (Printer.Handle, LOGPIXELSX) / GetDeviceCaps (B.Canvas.Handle, LOGPIXELSX); scaley: = GetDeviceCaps (Printer.Handle, LOGPIXELSY) / GetDeviceCaps (B.Canvas.Handle, LOGPIXELSY); Printer.Canvas.StretchDraw (Rect (0,0, round (B.Width * scalex), round (B.Height * scaley)), B); end;



MrBeer   (2001-12-16 21:48) [3]

A esli tak napisatj?
// ....
scalex: = GetDeviceCaps (Printer.Handle, LOGPIXELSX) / GetDeviceCaps (GetDC (0), LOGPIXELSX); scaley: = GetDeviceCaps (Printer.Handle, LOGPIXELSY) / GetDeviceCaps (GetDC (0), LOGPIXELSY);



Pages: 1 whole branch

Forum: "Main";
Current archive: 2002.01.08;
Download: [xml.tar.bz2];

Top









Memory: 0.82 MB
Time: 0.023 c
3-21969
Kozhanov
2001-11-30 18:31
2002.01.08
OBDC driver options


1-22221
Sour
2001-12-16 21:00
2002.01.08
Resources


3-21965
Serge
2001-12-05 06:13
2002.01.08
FoxPro indexing


1-22225
Reyst
2001-12-16 15:56
2002.01.08
Could not save resource to file


1-22108
Michael
2001-12-19 19:10
2002.01.08
Long printing on matrix printer





afrikaans albanian Arabic armenian azerbaijani basque belarusian bulgarian catalan Chinese (Simplified) Chinese (Traditional) croatian Czech danish Dutch English estonian filipino finnish French
galician georgian German greek haitian Creole hebrew Hindi hungarian icelandic indonesian Irish italian japanese Korean latvian lithuanian macedonian malay maltese norwegian
persian polish portuguese Romanian russian serbian slovak Slovenian Español swahili Swedish thai turkish Ukrainian urdu vietnamese welsh yiddish bengali bosnian
cebuano Esperanto gujarati hausa hmong igbo javanese kannada khmer lao latin maori marathi mongolian nepali punjabi somali tamil telugu yoruba
zulu
English French German Italian Portuguese Russian Spanish