Page 1 of 1

Problem with drawing raster images using TRVReportHelper

Posted: Wed Feb 27, 2008 6:41 am
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.

Posted: Wed Feb 27, 2008 7:25 am
by Sergey Tkachenko
Is this a screen canvas?

Posted: Fri Feb 29, 2008 5:48 am
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;

Posted: Fri Feb 29, 2008 11:30 am
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.

Posted: Fri Feb 29, 2008 1:02 pm
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.

Posted: Sat Mar 01, 2008 9:24 am
by Sergey Tkachenko
It always worked before. Please send me your RVF file

Posted: Mon Mar 03, 2008 6:14 am
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?

Posted: Mon Mar 03, 2008 4:53 pm
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...