-
July 13th, 2010, 11:54 AM
#1
Getting ideas for a graph
I'm trying to figure out the easiest and best way to perform this task:
I have two PGM (portable gray map) images and i need to put one above the other in a MFC window. Then I need to link them with lines and draw some circles in them.
I thought of using a modal window and a picture box like a canvas (container). Then using DC (device context) to draw on it in the OnPaint event of the window. The PGM format has to be read, I think I cannot escape this manual duty..
All of this sound a bit complicated and (possibly) messy.
Someone has a better idea? I ask here before I start this job because I'm not an expert like most of you.
-
July 13th, 2010, 12:36 PM
#2
Re: Getting ideas for a graph
Well, you probably need to create an owner-drawn static control and do the drawing yourself. In there you need to create a memory device context (or DC) for the one provided by the OS and then use it to combine two of your PGM images. I'm not sure if GDI (or even GDI+) can support those. If so, I'll let someone else explain it. If not, and that's how I'd do it, I would read both PGM's into memory and then combine them. You can find stuff online on the PGM specification, like this one for instance. Then you will need to convert it into pixels visible by the DC. For that you may want to obtain a DIB Section to the memory DC you got earlier by using the CreateDIBSection and then write your combined PGM data into it directly. After that you will need to transfer the resulting data from a memory DC into the one provided for the static control using BitBlt() or maybe even StretchBlt() to enable stretching for different static control sizes.
-
July 14th, 2010, 01:57 AM
#3
Re: Getting ideas for a graph
Excepted for the CreateDIBSection the method is almost what I thought: thanks!
I need to draw on the OnPaint event right?
-
July 14th, 2010, 02:13 AM
#4
Re: Getting ideas for a graph
No, you set the SS_OWNERDRAW flag and override WM_DRAWITEM notifications (or the MFC analog) for the static control.
-
July 14th, 2010, 03:57 AM
#5
Re: Getting ideas for a graph
Thank you, if I have more troubles I'll let you know
-
July 14th, 2010, 04:16 AM
#6
Re: Getting ideas for a graph
-
July 16th, 2010, 04:02 AM
#7
Re: Getting ideas for a graph
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|