我从数据库里调用的图片通过printer.canvas打印但是图片打印出来很小根本无法看清楚,应该怎么解决请大家帮忙指点一下

解决方案 »

  1.   

    // 在image2中画image1中的图像
      image2.Canvas.StretchDraw(image1.ClientRect, image1.Picture.Graphic);
      // 是不是你的 Rect太小了
      // 取打印机每英寸的象素数,一般在几百以上
      x := GetDeviceCaps(printer.Handle, LOGPIXELSX);
      y := GetDeviceCaps(printer.Handle, LOGPIXELSY);
      // 一般显示器每英寸的象素数是96
      pixels := 96;
      // 实际大小
      printer.Canvas.StretchDraw(Rect(Point(0, 0), Point(image1.Width * x div pixels, image1.Height * y div pixels)), image1.Picture.Graphic);
      

  2.   

    printer.Canvas.StretchDraw(Rect(Point(0, 0), Point(image1.Width * x div pixels, image1.Height * y div pixels)), image1.Picture.Graphic);
    当然是左上角,因为Point(0, 0)。
    假如要在左10毫米,上20毫米处打印该图像:
    pos := Point(Round(10 * x / 25.4), Round(20 * y / 25.4));
    x为打印机每英寸的象素数,x / 25.4为打印机的毫米单位。
      

  3.   

    但是这样改完之后图象也变大了,我想把图片打印在A4纸的中间,chinasdp() 能不能给出具体代码
    我的代码如下:
      bmp := tbitmap.create;
      BlobStream := TADOBlobStream.Create(TBlobField(ADOQuery1.Fields[0]), bmRead);
      bmp.LoadFromStream(BlobStream);
      printer.BeginDoc;
      x := GetDeviceCaps(printer.Handle, LOGPIXELSX);
      y := GetDeviceCaps(printer.Handle, LOGPIXELSY);
      // 一般显示器每英寸的象素数是96
      pixels := 96;
      // 实际大小 printer.Canvas.StretchDraw(Rect(Point(round(100 * x / 25.4), Round(100 * y / 25.4)),  Point(image1.Width * x div pixels, image1.Height * y div pixels)), bmp);  printer.EndDoc;
    请帮忙指点一下,先谢谢
      

  4.   

    不会吧,把图片先放到image控件上看看!
      

  5.   

    chinasdp() 谢谢你的帮忙,希望你能再次帮忙解决一下
    我放到控件上之后打印也是这种效果,怎样才能把图象翻转过来
    以下是我实现的代码,请指教
      ADOQuery2.Active := false;
      ADOQuery2.Parameters.ParamByName('dphao').value := fhno.Fields[0].AsString;
      ADOQuery2.Active := true;
      bmp := tbitmap.create;
      BlobStream := TADOBlobStream.Create(TBlobField(ADOQuery2.Fields[0]), bmRead);
      bmp.LoadFromStream(BlobStream);
      printer.Canvas.StretchDraw(Rect(4200, 2700, 3600, 2400), bmp);
      printer.EndDoc;
      bmp.Free;