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.56 MB
Time: 0.04 c
4 - 22458
Ajax
2001-10-31 17:50
2002.01.08
TColor and RGB


6 - 22308
Igor
2001-10-14 09:44
2002.01.08
Data exchange between client and server in Delphi


4 - 22489
Skiv
2001-11-05 09:55
2002.01.08
Display version * .exe


3 - 21906
Yuri Zhukov
2001-11-21 09:40
2002.01.08
Oracle ADO vs DOA - fido7.ru.delphi.db


6 - 22268
Voha
2001-10-05 13:25
2002.01.08
There is no referer parameter in the WebBrowser component.





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 Spanish 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