Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Chris Miller on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

image printing

Status
Not open for further replies.

jb386

Programmer
Apr 11, 2003
3
AU
Hi I hope someone can help me with this as I am a total newbie (no programming experience at all) I got a copy of delphi 7 personal and decided to build a cd cover prog, everthing seems to work good except for one problem the covers all print at 100 mm * 100 mm,instesd of the original size,I have included the code for you to look at, thanks in advance
Jim
-----------------------------------------------------------------------
unit Unit1;

interface

uses
Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
Dialogs, LMDControl, LMDBaseControl, LMDBaseGraphicControl, LMDBaseLabel,
LMDInformationLabel, WinSkinData, WinSkinForm, LMDGraphicControl,
LMDBaseImage, LMDCustomLImage, LMDLImage, ExtCtrls, LMDCustomLabel,
LMDLabel, LMDScrollText, LMDBaseGraphicButton, LMDCustomShapeButton,
LMDShapeButton, LMDBaseShape, LMDRepeatedShape, Menus, jpeg,
LMDCustomControl, LMDCustomPanel, LMDCustomBevelPanel,
LMDCustomParentPanel, LMDBackPanel, LMDCustomComponent,
LMDContainerComponent, LMDBaseDialog, LMDTipDlg, ExtDlgs;

type
TForm1 = class(TForm)
WinSkinForm1: TWinSkinForm;
SkinData1: TSkinData;
LMDShapeButton1: TLMDShapeButton;
LMDShapeButton2: TLMDShapeButton;
Image1: TImage;
Image2: TImage;
LMDBackPanel1: TLMDBackPanel;
PrintDialog1: TPrintDialog;
OpenPictureDialog1: TOpenPictureDialog;
procedure LMDShapeButton1Click(Sender: TObject);
procedure Image1Click(Sender: TObject);
private
{ Private declarations }
public
{ Public declarations }
end;

var
Form1: TForm1;

implementation

{$R *.dfm}
uses
Printers;
procedure TForm1.LMDShapeButton1Click(Sender: TObject);
Var
ScaleX, ScaleY: Integer;
RR: TRect;
begin
with Printer do
begin
BeginDoc;

try
ScaleX := GetDeviceCaps(Handle, logPixelsX) div PixelsPerInch;
ScaleY := GetDeviceCaps(Handle, logPixelsY) div PixelsPerInch;


RR := Rect(0, 0, Image1.picture.Width * scaleX, Image1.Picture.Height * ScaleY);
Canvas.StretchDraw(RR, Image1.Picture.Graphic);



finally
EndDoc;

end;
end;
end;
procedure TForm1.Image1Click(Sender: TObject);
begin
if OpenPictureDialog1.Execute then
try
Image1.Picture.LoadFromFile(OpenPictureDialog1.FileName);
except end;
end;


end.
 
Your canvas width and height are probably too small so it might be worth setting your canvas width and height to the desired dimensions first. Then it should stretchdraw the image to that size.

If this doesn't work then step through your code at run-time and check the values of scaleX and scaleY

Hope this helps

Clive [infinity]
Ex nihilo, nihil fit (Out of nothing, nothing comes)
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top