Drawing canvas backimage

TeeChart for ActiveX, COM and ASP
Post Reply
Activex7
Newbie
Newbie
Posts: 16
Joined: Wed Aug 16, 2006 12:00 am

Drawing canvas backimage

Post by Activex7 » Fri Sep 16, 2011 8:35 pm

Hi,

This is my issue, I am using the imagetool from teechart tools menu to draw a image on the background. However one issue is there is no way to specify where to draw the image, i.e the co-ordinates or starting point. The image tool just draws a image associated with a series. Is there a way to specify the limits from where to start drawing ?

Now I see that there is another method associated with the canvas called draw, However draw needs the image as a LPUNKNOWN type, How do I generate this type ?
Tchartctrl1.GetCanvas().Draw(x,y,(LPUNKNOWN) ??);

My requirement is to be able to exactly coincide the background image with respect to a series, how can I achieve this ?
Thanks,

Narcís
Site Admin
Site Admin
Posts: 14730
Joined: Mon Jun 09, 2003 4:00 am
Location: Banyoles, Catalonia
Contact:

Re: Drawing canvas backimage

Post by Narcís » Mon Sep 19, 2011 8:38 am

Hi ActiveX7,
This is my issue, I am using the imagetool from teechart tools menu to draw a image on the background. However one issue is there is no way to specify where to draw the image, i.e the co-ordinates or starting point. The image tool just draws a image associated with a series. Is there a way to specify the limits from where to start drawing ?
You could try custom drawing on the chart canvas assigning an image to the canvas.brush and draw a rectangle in the position you wish. This should be done in TChart's OnAfterDraw event or if you need the image being painted behind the series you could try with other chart or series drawing events.
Now I see that there is another method associated with the canvas called draw, However draw needs the image as a LPUNKNOWN type, How do I generate this type ?
Tchartctrl1.GetCanvas().Draw(x,y,(LPUNKNOWN) ??);
LPUNKNOWN is the same as "IUnknown *", or a pointer to an object which supports the IUnknown interface. This interface is the base class for every COM and ActiveX class. You would use it to pass a reference to a COM or ActiveX object when you don't know or don't care what interfaces it actually supports. It is for reference counting and finding other interfaces an object supports.

I'm sorry but I'm not a Visual C++ specialist. Probably searching on the internet you'll find usage examples. Alternatively you can use canvas' AssignImage and Rectangle methods:

Code: Select all

	m_Chart1.GetCanvas().GetBrush().AssignImage(ImageHandle);
	m_Chart1.GetCanvas().Rectangle(Left, Top, Right, Bottom);
My requirement is to be able to exactly coincide the background image with respect to a series, how can I achieve this ?
This will slightly vary depending on the series style you are using but you should calculate series screen coordinates using its CalcXPos and CalcYPos methods.
Best Regards,
Narcís Calvet / Development & Support
Steema Software
Avinguda Montilivi 33, 17003 Girona, Catalonia
Tel: 34 972 218 797
http://www.steema.com
Image Image Image Image Image Image
Instructions - How to post in this forum

Activex7
Newbie
Newbie
Posts: 16
Joined: Wed Aug 16, 2006 12:00 am

Re: Drawing canvas backimage

Post by Activex7 » Mon Sep 19, 2011 9:05 pm

m_Chart1.GetCanvas().GetBrush().AssignImage(ImageHandle);

The assign image method above takes a long (ImageHandle) as a parameter, is this only meant for images in the resource file ? I want to load image from a file. Do you have an example ?

Thanks,

Narcís
Site Admin
Site Admin
Posts: 14730
Joined: Mon Jun 09, 2003 4:00 am
Location: Banyoles, Catalonia
Contact:

Re: Drawing canvas backimage

Post by Narcís » Tue Sep 20, 2011 8:50 am

Hi Activex7,

To load images from a file you can use LoadImage method:

Code: Select all

	m_Chart1.GetCanvas().GetBrush().LoadImage(fileName);
An example can be found here.
Best Regards,
Narcís Calvet / Development & Support
Steema Software
Avinguda Montilivi 33, 17003 Girona, Catalonia
Tel: 34 972 218 797
http://www.steema.com
Image Image Image Image Image Image
Instructions - How to post in this forum

Activex7
Newbie
Newbie
Posts: 16
Joined: Wed Aug 16, 2006 12:00 am

Re: Drawing canvas backimage

Post by Activex7 » Tue Sep 20, 2011 5:04 pm

Hi Narcis.

Thanks for your help in this issue. I have a couple of questions

a)When I use the canvas to draw a image, I cannot zoom it ? like the behavior of the chartimage tool ?

b) Also the image drawn using the canvas is drawn over the series, Can I make to draw below the series ?

Thanks,

Narcís
Site Admin
Site Admin
Posts: 14730
Joined: Mon Jun 09, 2003 4:00 am
Location: Banyoles, Catalonia
Contact:

Re: Drawing canvas backimage

Post by Narcís » Wed Sep 21, 2011 7:08 am

Hi Activex7,
a)When I use the canvas to draw a image, I cannot zoom it ? like the behavior of the chartimage tool ?
I'm afraid not.
b) Also the image drawn using the canvas is drawn over the series, Can I make to draw below the series ?
You could try using chart's OnBeforeDraw or OnBeforeDrawSeries events instead of OnAfterDraw.
Best Regards,
Narcís Calvet / Development & Support
Steema Software
Avinguda Montilivi 33, 17003 Girona, Catalonia
Tel: 34 972 218 797
http://www.steema.com
Image Image Image Image Image Image
Instructions - How to post in this forum

Activex7
Newbie
Newbie
Posts: 16
Joined: Wed Aug 16, 2006 12:00 am

Re: Drawing canvas backimage

Post by Activex7 » Wed Sep 21, 2011 3:19 pm

Thanks narcis, So for my purposes I would have to stick with the chartimage tool.

The question I have is, what kind of image manipulation does it take to make a image fit well, if the series is a point series. Also can I get the resolution from Teechart ? I am guessing if I can get the resolution/width of the chart and can modify the image accordingly I might be able to get a more better fit ?

For example, say if have a series (point) with some data points and then I have a image with bubbles in it, where each of the bubbles should coincide with a point from the series, I am using the chart image tool as I want the zoom functionality, what can I do to make this image fit better ? assuming the image and series are in the same boundaries.

Thanks,

Narcís
Site Admin
Site Admin
Posts: 14730
Joined: Mon Jun 09, 2003 4:00 am
Location: Banyoles, Catalonia
Contact:

Re: Drawing canvas backimage

Post by Narcís » Thu Sep 22, 2011 8:44 am

Hi Activex7,
The question I have is, what kind of image manipulation does it take to make a image fit well, if the series is a point series. Also can I get the resolution from Teechart ? I am guessing if I can get the resolution/width of the chart and can modify the image accordingly I might be able to get a more better fit ?
You can get ChartRect boundaries but you won't be able to resize the Image tool unless you format the image outside TeeChart and add it already formated.
For example, say if have a series (point) with some data points and then I have a image with bubbles in it, where each of the bubbles should coincide with a point from the series, I am using the chart image tool as I want the zoom functionality, what can I do to make this image fit better ? assuming the image and series are in the same boundaries.
An alternative could be use ImagePoint series where you can set a pointer image and a point series on top with same values. Would this fit your needs?
Best Regards,
Narcís Calvet / Development & Support
Steema Software
Avinguda Montilivi 33, 17003 Girona, Catalonia
Tel: 34 972 218 797
http://www.steema.com
Image Image Image Image Image Image
Instructions - How to post in this forum

Post Reply