Screen device image quality (or; how to override)
Hello,
this question is mostly similar to a thread previously posted by 'David
Farrell-Garcia' entitled 'Image Quality in Reports', but there was no
answer in that one.
When I display my report in a TppViewer, the image quality is quite poor
due to the way it StretchDraws it. Since I've written a TppViewer
descendant anyways for some extra functionality (like being able to drag
the view to scroll it), I tried to override the image drawing behaviour
for the screen device.
I ran into a few problems, which all come down to an issue I've run across
many times while trying to extend the ReportBuilder component; most
methods aren't defined as virtual, even methods like the DoEventName ones
(in my viewer descendant I had to create a communicator to listen to it's
own notifications, which could've been solved by simply overriding
DoOnPageChanged if it were virtual).
But to get back to the issue I'm currently having; TppViewer is linked to
TppScreenDevice in such a way that it can't be overridden without
modifying the source (not a preferable option). This means I can't
override TppScreenDevice.Draw either (DrawImage isn't virtual
unfortunately) to hook into the image drawing process.
Therefore, I would like to request the feature to be able to override the
screen device used in the viewer (or for it to use the registered device
class for dtScreen). Of course, any other solution to improving image
quality is also welcome.
Thanks in advance,
Mark van Renswoude
this question is mostly similar to a thread previously posted by 'David
Farrell-Garcia' entitled 'Image Quality in Reports', but there was no
answer in that one.
When I display my report in a TppViewer, the image quality is quite poor
due to the way it StretchDraws it. Since I've written a TppViewer
descendant anyways for some extra functionality (like being able to drag
the view to scroll it), I tried to override the image drawing behaviour
for the screen device.
I ran into a few problems, which all come down to an issue I've run across
many times while trying to extend the ReportBuilder component; most
methods aren't defined as virtual, even methods like the DoEventName ones
(in my viewer descendant I had to create a communicator to listen to it's
own notifications, which could've been solved by simply overriding
DoOnPageChanged if it were virtual).
But to get back to the issue I'm currently having; TppViewer is linked to
TppScreenDevice in such a way that it can't be overridden without
modifying the source (not a preferable option). This means I can't
override TppScreenDevice.Draw either (DrawImage isn't virtual
unfortunately) to hook into the image drawing process.
Therefore, I would like to request the feature to be able to override the
screen device used in the viewer (or for it to use the registered device
class for dtScreen). Of course, any other solution to improving image
quality is also welcome.
Thanks in advance,
Mark van Renswoude
This discussion has been closed.
Comments
Thanks for the feedback. The protected routines you mention will be made
virtual for the next release of ReportBuilder. We will also research
allowing the replacement of the screen device without also replacing the
viewer. We value any input you can give us as we move forward with RB. If
there are any other routines you would like made virtual, please let us
know.
Currently, it should be possible to descend from the TppImage component and
have it create a custom drawcommand. From the new drawcommand you can
override the Draw routine taking complete control over how the image is
drawn to the report. This is similar to the way the TppRichText and
TppBarCode components function.
--
Regards,
Nico Cizik
Digital Metaphors
http://www.digital-metaphors.com
Nico Cizik
Digital Metaphors
http://www.digital-metaphors.com
screen device). I solved the problem by resampling the image in a
different way depending on the DeviceType...
I implemented the onDrawCommandCreate for the TppImage component:
var
mem: TMemoryStream;
begin
if report.DeviceType = 'Screen' then
begin
mem := TMemoryStream.Create;
try
DatasetIMAGE.SaveToStream(mem); //load image from
wherever //(file, blob, ...)
//DO RESAMPLING HERE AND SAVE RESULT BACK IN MEMORYSTREAM
mem.Position := 0;
TppDrawImage(aDrawCommand).Picture.Bitmap.LoadFromStream(mem);
finally
mem.Free;
end;
end
else if rptIzpis.DeviceType = 'Printer' then
begin
mem := TMemoryStream.Create;
try
DatasetIMAGE.SaveToStream(mem); //load image from
wherever //(file, blob, ...)
//DO DIFFERENT RESAMPLING HERE AND SAVE RESULT BACK IN //MEMORYSTREAM
mem.Position := 0;
TppDrawImage(aDrawCommand).Picture.Bitmap.LoadFromStream(mem);
finally
mem.Free;
end;
end;
This solution seems working fine for me, since I can define where the
image is being drawn (screen on printer).
Hope this will help anyone. If you see anything wrong with this or any
possible problems, please advice on it.
Regards, VasjaS