Page 1 of 1

Pixelated Bitmap

Posted: Wed Jun 27, 2007 4:01 pm
by 9336214
I am creating a bitmap from a TChart at run time to print in a report. (One series in the chart has Transparent set to True, which means I can not use the WMF format as this is not supported).

I use the following code:

lBmp.Width := lRect.Right;
lBmp.Height := lRect.Bottom;
lChart.Draw(lBmp.Canvas, lRect);

Problem is that the bitmap shows up pixelated--is there any way to improve the quality of the printed image? (I looked at th properties of the TBitmap, which would seem the natural place, but could not find it). I know I could increaste the values of .Right and .Bottom (e.g. double the values) but then the fonts are too small.

Any suggestions?

Posted: Thu Jun 28, 2007 8:31 am
by narcis
Hi Ed,

One way to enhance the quality of the bitmap to be printed would be increasing its size.

Posted: Thu Jun 28, 2007 1:50 pm
by 9336214
narcis wrote:One way to enhance the quality of the bitmap to be printed would be increasing its size.
Yes, but increasing the size decreases the font size. I know, then increase the font size.... and that becomes much more work. I thought that there must be an easier way to do this. Maybe not.

Posted: Mon Jul 02, 2007 11:54 am
by Pep
Hi Ed,

I'm afraid the easiest way is (as you said) to increase the Font size depending on the image size, not using the Font.Size property, but the FontZoom, i.e :

Code: Select all

procedure TForm1.BitBtn1Click(Sender: TObject);
begin
  if SaveDialog1.Execute then  { <-- ask for a filename first }
  begin
   { SAVE IT !! }

    Chart1.Width := Chart1.Width + Chart1.Width;
    Chart1.Height := chart1.Height + chart1.Height;
    Chart1.Aspect.FontZoom := 140;


{    CLIPPING WORKS FINE BUT DO NOT ALLOW MOVEABLE OR RESIZEABLE METAFILES }
{    TO FORCE CLIPPING WITH METAFILES UNCOMMENT THIS LINE: }
{    TeeClipWhenMetafiling:=True;  }

    Chart1.SaveToMetafile(SaveDialog1.FileName);

   { THIS METHOD CAN BE USED TOO: }
(*
      Chart1.SaveToMetafileRect( SaveDialog1.FileName,
      Rect( 0,0, round(21{cm}*37.8), round(10{cm}*37.8)));
*)
{   ( this equals to 96 * 21 / 2.54 , 96 * 10 /2.54 )   }

    { now it's loaded HERE ! }
    Image1.Picture.LoadFromFile(SaveDialog1.FileName);
    Image1.Refresh;

    Chart1.Width := Chart1.Width - Chart1.Width;
    Chart1.Height := chart1.Height - chart1.Height;
    Chart1.Aspect.FontZoom := 100;
  end;
end;