Re: Graphics objects --- passing the object vs the handle

Tech-Archive recommends: Fix windows errors by optimizing your registry



I think rendering to a bitmap and then painting that with GDI+ is the only way to go. I don't see why you think the result will be poor.. Am I missing something important?

--
--
Bob Powell [MVP]
Visual C#, System.Drawing

Ramuseco Limited .NET consulting
http://www.ramuseco.com

Find great Windows Forms articles in Windows Forms Tips and Tricks
http://www.bobpowell.net/tipstricks.htm

Answer those GDI+ questions with the GDI+ FAQ
http://www.bobpowell.net/faqmain.htm

All new articles provide code in C# and VB.NET.
Subscribe to the RSS feeds provided and never miss a new article.


"Michael C" <nospam@xxxxxxxxxx> wrote in message news:%23sSLbhWgHHA.668@xxxxxxxxxxxxxxxxxxxxxxx
"Jeff" <jrush@xxxxxxx> wrote in message news:1176841241.275965.313110@xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx
I have designed a set of classes which all accept a graphics object
and then render lines, rectanges, text, etc to that object. There is
a "parent" class which controls the instantiation of each class and
also calls the render method for each class, passing the form's
graphic object. This parent class also controls the zooming in/out
via a matrix. Everything works wonderfully.

I now have a need for an additional class which will accept a PDF file
and render it onto the same form. I want to build this class just
like the others, which means giving it a method which accepts a
Graphics object. I'm using a 3rd party control by Visage as part of
this new class. This Visage control even has a method called
"PaintToDC". The documentation for this method is as follows:

"PaintToDC (DC: HDC; em11, em12, em21, em22, dx, dy: Double)
Render the current page to the device context specifed from DC
parameter.the additional
parameters are for specifying the tranformation matrix used for
rendering.
By using transformation matrixes you will be able to scale/rotate/skew
etc the rendered page.
The default transformation matrix is 1,0,0,1,0,0"

The Problem: This control does not mesh with my current setup. The
"paint" does not scroll like the other classes. Is this because I'm
doing a GetHDC and then a ReleaseHDC on the Graphics object as opposed
to simply passing the Graphics object ByRef? If so, is there
something I can do within my "parent" class which will force this
Visage control to behave like my other classes when it comes to
scrolling and zooming?

AFAIK, you're stuck. It looks like the control does not use GDI+ which is what is needed to use matrix transforms. It appears the control is using plain old GDI which simply does not support this feature. You could paint to a bitmap and then paint that bitmap to the form but the result will be poor. The only solution I can think of is to find a control that does support GDI+ but I don't think that's going to be easy.

BTW, you should pass objects around ByVal generally.

Michael


.



Relevant Pages

  • Graphics objects --- passing the object vs the handle
    ... I have designed a set of classes which all accept a graphics object ... and then render lines, rectanges, text, etc to that object. ... This parent class also controls the zooming in/out ... This Visage control even has a method called ...
    (microsoft.public.dotnet.framework.drawing)
  • Re: Graphics objects --- passing the object vs the handle
    ... and then render lines, rectanges, text, etc to that object. ... This parent class also controls the zooming in/out ... This Visage control even has a method called ... doing a GetHDC and then a ReleaseHDC on the Graphics object as opposed ...
    (microsoft.public.dotnet.framework.drawing)
  • Re: Problems with translate transform
    ... on then you'll get a different Graphics object to that of the controls ... transformations to it and render it to drawing surface of control ( ... of control which seem to be related to translation offsets of buffered ...
    (microsoft.public.dotnet.framework.drawing)
  • Re: An Edit Control (Common Control) that uses GDI+ fonts
    ... I dont think it's of any use if you just make it use GDI+ font since YOU ... wont be drawing in the control. ... to create a GDI+ graphics object by calling the constructor ...
    (microsoft.public.win32.programmer.gdi)
  • Re: GDI+ Performance Question
    ... what is this Canvas object that you are using for drawing? ... I've been reading alot about how GDI+ does not ... The rendering algorithm is pretty sound, it'll only render the parts of the score that need to be. ... For performance reasons, I'm drawing to a bitmap and during scrolling, I'm actually only rendering parts of the bitmap, in order to keep performance under control, but I don't like that approach. ...
    (microsoft.public.dotnet.framework.drawing)