Board index » delphi » TBitmap has poor print quality in Delphi 3.0

TBitmap has poor print quality in Delphi 3.0

Ok. Here is how my day is going so far...

1. WindowsNT boots up only about 1/2 the time without locking up.
2. I got a letter from the police that says my 1987 chrysler has been
impounded. (I don't own a 1987 chrysler).
3. Now this...
    The simple logic below will print out a bitmap just beautifully when i'm
using Delphi 2.0:

procedure TForm1.Button1Click(Sender: TObject);
  Var
    MyBitmap : TBitMap;

  begin
    MyBitmap := TBitMap.Create;
    With MyBitmap do begin
       LoadFromFile ('c:\clown.bmp');
       Printer.BeginDoc;
       Printer.Canvas.StretchDraw (Rect (1000, 1000, 2000, 2000), MyBitmap);
       Printer.EndDoc;
       Free;
    end;
end;

    The weird thing is though, when I started using Delphi 3.0 the print
quality of the image is terrible.  I looks like it is printing in a much
lower resolution, or using coarse dithering.  Playing with the graphics
settings
for my printer hasn't helped.  I have an HP Laserjet 4si.

Even stranger, when I get WindowsNT up, the program prints fine.  It prints
fine
if i'm using Delphi 2.0 or Delphi 3.0.

Now my boss is threatening to go back to Delphi 2.0.  So, any help in this
would
be greatly appreciated.

Thanks in advance,
Charles McAllister

P.S.  The first person to fix this problem gets a 1987 chrysler :)

 

Re:TBitmap has poor print quality in Delphi 3.0


Quote
Charles McAllister wrote in message <6olqj4$9a...@forums.borland.com>...
>Ok. Here is how my day is going so far...
>2. I got a letter from the police that says my 1987 chrysler has been
>impounded. (I don't own a 1987 chrysler).

My day's been going a little better:  I received a letter in the mail from
an attorney's that someone is going bankrupt and I should file a claim for
money they owe me.  But I've never heard of these people!

Quote
>       Printer.Canvas.StretchDraw (Rect (1000, 1000, 2000, 2000),

MyBitmap);

You want to use StretchDIBits instead of StretchDraw.  Take a look at
Printer Demo #1 on the Printer Projects page in my Computer Lab.  (Start in
the "Other Projects" section.)  The example shows the differences among
Draw, StetchDraw and StretchDIBits.

efg
_________________________________________
efg's Computer Lab:  http://infomaster.net/external/efg

Earl F. Glynn                 E-Mail:  EarlGl...@att.net
MedTech Research Corporation, Lenexa, KS  USA

Re:TBitmap has poor print quality in Delphi 3.0


Hi Charles,

you should use StretchDIBits instead - that have worked for me!

------8<-----snip-------------8<-------snap-------------8<---------snip---------8<------snap

procedure MemFree(Ptr: Pointer; Size: Longint);
begin
  if Size < 65535 then
    FreeMem(Ptr, Size)
  else
    GlobalFreePtr(Ptr);
end;

  {Prints BitMap }
procedure DrawImage(Canvas: TCanvas; DestRect: TRect; ABitmap: TBitmap);
var
  Header, Bits: Pointer;
  HeaderSize: Integer;
  {$IfDef Win32}                   {Checks if using Delphi 2.0}
  BitsSize : Integer;
  {$Else}
  BitsSize : LongInt;
  {$EndIf}
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.Left, DestRect.Bottom - DestRect.Top,
        0, 0, ABitmap.Width, ABitmap.Height, Bits, TBitmapInfo(Header^),
        DIB_RGB_COLORS, SRCCOPY);
  finally
    MemFree(Header, HeaderSize);
    MemFree(Bits, BitsSize);
  end;
end;

procedure TForm1.Button1Click(Sender: TObject);
begin
  Printer.BeginDoc;

  DrawImage(Printer.Canvas,
            Rect(20, 30, 20+(image1.picture.bitmap.width * 7),
30+(image1.picture.bitmap.height * 7)),
            image1.picture.bitmap);

  Printer.EndDoc;
end;
------8<-----snip-------------8<-------snap-------------8<---------snip---------8<------snap

Quote
Charles McAllister wrote:
> Ok. Here is how my day is going so far...

>        Printer.BeginDoc;
>        Printer.Canvas.StretchDraw (Rect (1000, 1000, 2000, 2000), MyBitmap);

[...]

Quote
>     The weird thing is though, when I started using Delphi 3.0 the print
> quality of the image is terrible.  I looks like it is printing in a much
> lower resolution, or using coarse dithering.  Playing with the graphics
> settings

[...]

Other Threads