Problem with drawing raster images using TRVReportHelper

General TRichView support forum. Please post your questions here
Post Reply
SergeyRock
Posts: 46
Joined: Fri Jul 21, 2006 9:16 am
Contact:

Problem with drawing raster images using TRVReportHelper

Post by SergeyRock »

When i try to draw raster images on canvas using TRVReportHelper, some images don`t appeare on target canvas, but the image bounds are saved. Current problem does not exists in TRVPrint. Also, if the images are in vector format there is no problem in TRVReportHelper.

I use TRichView 1.9.40.2. If it`s necessary i can send you RVF.

Help me, please.
Sergey Tkachenko
Site Admin
Posts: 17559
Joined: Sat Aug 27, 2005 10:28 am
Contact:

Post by Sergey Tkachenko »

Is this a screen canvas?
SergeyRock
Posts: 46
Joined: Fri Jul 21, 2006 9:16 am
Contact:

Post by SergeyRock »

Sergey Tkachenko wrote:Is this a screen canvas?
It`s a metafile canvas.

Code: Select all

const
  VERYLARGEVALUE = $FFFFFFF;
var
  m : TmetaFile;
  mc : TmetaFileCanvas;
  S: TMemoryStream;
  RVHeight : Integer;
begin
  S:= TMemoryStream.Create;
  try
    rvEdit.SaveRVFToStream(S, False);
    S.Position := 0;
    RVReport.RichView.Clear();
    RVReport.RichView.LoadRVFFromStream(S);
  finally
    S.Free;
  end;

  m := TMetafile.Create;
  try
    RVHeight := Trunc(rvEdit.ClientWidth * 0.724);
    m.Width := rvEdit.ClientWidth;
    m.Height := RVHeight;

    mc := TMetafileCanvas.Create(m, 0);
    try
      RVReport.Init(mc, rvEdit.ClientWidth);
      while RVReport.FormatNextPage(VERYLARGEVALUE) do
        ;

      RVReport.DrawPage(1, mc, True, RVHeight);
    finally
      mc.Free;
    end;

  finally
    m.Free;
  end;
end;
Sergey Tkachenko
Site Admin
Posts: 17559
Joined: Sat Aug 27, 2005 10:28 am
Contact:

Post by Sergey Tkachenko »

If Preview parameter of RVReport.DrawPage is True, graphic.StretchDraw is used for drawing images. Try to pass False instead. Images will be drawn differently, in a printer-compatible way.
SergeyRock
Posts: 46
Joined: Fri Jul 21, 2006 9:16 am
Contact:

Post by SergeyRock »

Sergey Tkachenko wrote:If Preview parameter of RVReport.DrawPage is True, graphic.StretchDraw is used for drawing images. Try to pass False instead. Images will be drawn differently, in a printer-compatible way.
It is the same with false-param.
Try to use my code. Make RVF wich contains several raster images.
Sergey Tkachenko
Site Admin
Posts: 17559
Joined: Sat Aug 27, 2005 10:28 am
Contact:

Post by Sergey Tkachenko »

It always worked before. Please send me your RVF file
SergeyRock
Posts: 46
Joined: Fri Jul 21, 2006 9:16 am
Contact:

Post by SergeyRock »

Sergey Tkachenko wrote:It always worked before. Please send me your RVF file
It`s my mistake.
After drawing on metafile canvas using TRVReportHelper, I try to scale this metafile to other metafile with lower aspect-ratio.
This operation breaks some raster images, but text has correct output.

Sorry for offtopic, may be you know the solve of this problem?
Sergey Tkachenko
Site Admin
Posts: 17559
Joined: Sat Aug 27, 2005 10:28 am
Contact:

Post by Sergey Tkachenko »

I am not sure that you mean by "scale this metafile to other metafile with lower aspect-ratio".
If you play metafile to canvas of different device (for example, playing metafile on printer canvas), many commands for drawing raster images may fail. But if Preview=False in RVReportHelper.DrawPage, images must be drawn in a safe way...
Post Reply