Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- procedure PrintSelectedImages;
- var
- LImageFiles : array of string;
- LIdx, LTotal : integer;
- LBitmapRect, LPrinterRect : TRect;
- LPicture : TPicture;
- LBitmap : TBitmap;
- begin
- // temporary store the selected image filenames
- SetLength( LImageFiles, images_index );
- LTotal := 0;
- for LIdx := 0 to images_index - 1 do
- if Checks[LIdx].Checked then
- begin
- LImageFiles[LTotal] := images[LIdx].Hint;
- Inc( LTotal );
- end;
- SetLength( LImageFiles, LTotal );
- // no images selected
- if LTotal = 0 then
- begin
- MessageDlg( 'No Images Selected!', mtInformation, [mbOK], 0 );
- Exit;
- end;
- // printing images from the temp. array
- if PrintDialog1.Execute then
- begin
- LPicture := nil;
- LBitmap := nil;
- try
- Picture := TPicture.Create;
- Bitmap := TBitmap.Create;
- Printer.BeginDoc;
- for LIdx := Low( LImageFiles ) to High( LImageFiles ) do
- begin
- LPicture.LoadFromFile( LImageFiles[LIdx] );
- LBitmap.Assign( LPicture );
- // output bitmap to printer
- LBitmapRect := Rect( 0, 0, Bitmap.Width, Bitmap.Height );
- LPrinterRect := Rect( 0, 0, Printer.PageWidth, Printer.PageHeight );
- Printer.Canvas.CopyRect( LPrinterRect, Bitmap.Canvas, LBitmapRect );
- Printer.NewPage;
- end; // LIdx
- Printer.EndDoc;
- finally
- LPicture.Free;
- LBitmap.Free;
- end;
- end;
- end;
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement