DELPHI AREA
MESSAGE BOARD
 
 FAQFAQ   SearchSearch   MemberlistMemberlist   UsergroupsUsergroups   RegisterRegister 
 ProfileProfile   Log in to check your private messagesLog in to check your private messages   Log inLog in 

Bug in SimpleGraph ???

 
   Reply to topic    DELPHI AREA Forum Index -> DELPHI AREA's Products
View previous topic :: View next topic  
Author Message
P_G
Member


Joined: 14 Jun 2004
Posts: 21
Location: Germany

PostPosted: 14/06/04 11:21    Post subject: Bug in SimpleGraph ??? Reply with quote

SimpleGraph 1.21

First of all: Congratulations for this great component. It's very useful and stable.
But I noticed a bug in the new zoom-feature (or at least I think it's a bug): If the node contains a graphic, this graphic is not displayed properly when zooming. It seems theres a problem with the bounding-box.

C.U. P_G
Back to top
View user's profile
Kambiz
Administrator


Joined: 07 Mar 2003
Posts: 413
Location: Tehran, Iran

PostPosted: 14/06/04 13:15    Post subject: Reply with quote

I couldn't regenerate the case.

Could you please attach a screenshot and its associated sgp file?
Back to top
View user's profile Send e-mail Visit poster's website
P_G
Member


Joined: 14 Jun 2004
Posts: 21
Location: Germany

PostPosted: 14/06/04 14:39    Post subject: Sorry !!! Reply with quote

Sorry, Kambiz.
My fault - there's no bug in displaying graphics while zooming. The problem ocurred because I modificated the procedure TGraphNode.DrawBackground to use Metafiles instead of Bitmaps in graphics. This caused the bug I referred to (so I produced this bug by myself).
Nevertheless I do not have success in implementing this feature: I need the possibility of attaching a metafile or a bitmap into the node's picture.
Do you have any ideas?

C.U. P_G
Back to top
View user's profile
Kambiz
Administrator


Joined: 07 Mar 2003
Posts: 413
Location: Tehran, Iran

PostPosted: 14/06/04 17:36    Post subject: Reply with quote

The Background property of TGraphNode is TPicture. So, it can be assigned or loaded by any Delphi supported image format (Bitmap, Icon, JPEG, Metafile).

Code:
if SimpleGraph.Objects[I] is TGraphNode then
  TGraphNode(SimpleGraph.Objects[I]).Background.LoadFromFile('D:\Sample.wmf');

Code:
if SimpleGraph.Objects[I] is TGraphNode then
  TGraphNode(SimpleGraph.Objects[I]).Background := Image1.Picture;

Code:
if SimpleGraph.Objects[I] is TGraphNode then
  TGraphNode(SimpleGraph.Objects[I]).Background.Assign(AMetafile);

Code:
if SimpleGraph.Objects[I] is TGraphNode then
  TGraphNode(SimpleGraph.Objects[I]).Background.Graphic := ABitmap;
Back to top
View user's profile Send e-mail Visit poster's website
P_G
Member


Joined: 14 Jun 2004
Posts: 21
Location: Germany

PostPosted: 15/06/04 07:58    Post subject: Yip, I know this. Reply with quote

Kambiz wrote:
The Background property of TGraphNode is TPicture. So, it can be assigned or loaded by any Delphi supported image format (Bitmap, Icon, JPEG, Metafile).


This is true of course. There's only the problem that the DrawBackGround-procedure converts the Metafile to a Bitmap. So if you stretch the node, you can see the pixels of the graphic. To avoid this effect I tried to change the DrawBackGround to work with Metafiles (Stretch instead of StretchBLT). This worked fine but caused the discribed bug in the new version. Crying or Very sad
Any help of you would be apreciated.

C.U. P_G
Back to top
View user's profile
Kambiz
Administrator


Joined: 07 Mar 2003
Posts: 413
Location: Tehran, Iran

PostPosted: 15/06/04 09:12    Post subject: Reply with quote

Some printer drivers only accept DIB bitmaps to draw on their canvas. Althought, for a metafile that doesn't contain a DDB bitmap there's no problem. However, the code is written in a general manner.
Back to top
View user's profile Send e-mail Visit poster's website
P_G
Member


Joined: 14 Jun 2004
Posts: 21
Location: Germany

PostPosted: 15/06/04 09:26    Post subject: Interesting ... Reply with quote

Hi Kambiz,

Actually I didn't check printer results. I just saw the results on the monitor and it was a matter of quality for me. Is there no way to implement a workaround for the StretchBLT so that vectorgraphics are displayed properly on the monitor and the zoomfunction stills works correct?

C.U. P_G
Back to top
View user's profile
Kambiz
Administrator


Joined: 07 Mar 2003
Posts: 413
Location: Tehran, Iran

PostPosted: 15/06/04 15:08    Post subject: Reply with quote

The following code may help you.

Code:
procedure TGraphNode.DrawBackground(Canvas: TCanvas);
var
  Rgn: HRGN;
begin
  if (Background.Graphic <> nil) and (Background.Graphic is TMetaFile) then
  begin
    Rgn := CreateTargetRegion(Canvas);
    try
      SelectClipRgn(Canvas.Handle, Rgn);
    finally
      DeleteObject(Rgn);
    end;
    try
      PlayEnhMetaFile(Canvas.Handle, TMetaFile(Background.Graphic).Handle, BoundsRect);
    finally
      SelectClipRgn(Canvas.Handle, 0);
    end;
    Canvas.Brush.Style := bsClear;
  end;
end;
Back to top
View user's profile Send e-mail Visit poster's website
P_G
Member


Joined: 14 Jun 2004
Posts: 21
Location: Germany

PostPosted: 15/06/04 15:20    Post subject: Fantastic !!! Reply with quote

Thanks alot, Kambiz !
Back to top
View user's profile
Display posts from previous:   
   Reply to topic    DELPHI AREA Forum Index -> DELPHI AREA's Products All times are GMT
Page 1 of 1

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum
You cannot attach files in this forum
You can download files in this forum


Powered by phpBB 2.0.6 © 2001, 2002 phpBB Group