Problem w. Rectangle in DrawImage

Hello forum,
I'm trying to work with some alpha blending of images with GDI+, but I get errors.

g.DrawImage(&music, new Rectangle(x_pos, y_pos, x_pos+56, y_pos+56) ,x_pos, y_pos, 56, 56, UnitPixel, &imgattr);

It says the following errors about the Rectangle:

1
2
3
1>d:\dokumenter\programmering\visual c++\media player\media player\flow_menu.h(132): error C2061: syntax error : identifier 'Rectangle'
1>d:\dokumenter\programmering\visual c++\media player\media player\flow_menu.h(132): error C2143: syntax error : missing ';' before ')'
1>d:\dokumenter\programmering\visual c++\media player\media player\flow_menu.h(132): error C2143: syntax error : missing ';' before ')'


Any solutions to this problem?

Regards,

Simon H.A.
Compiler can't able to find definition of Rectangle.
please check the following,
1. Whether header file included or not where Rectangle() definition is there.
2. Check corresponding header file path added in Include Directories (-I).

NOTE : First find which header file holds Rectangle() definition
I tried to find the declaration of the Rectangle and it said it was in WinGDI.h.
The problem is, that I have already included it...
Rectangle is a function - It most likely should be a RECT structure.
have you checked the function information on MSDN??
I've checked on MSDN, and it says it needs a Rectangle.

1
2
3
4
5
6
7
8
9
10
11
public:
void DrawImage(
	Image^ image, 
	Rectangle destRect, 
	int srcX, 
	int srcY, 
	int srcWidth, 
	int srcHeight, 
	GraphicsUnit srcUnit, 
	ImageAttributes^ imageAttr
)

Point me at the msdn link where you got that information from - there is some confusion here.
You maybe reading the wrong funtion prototype on msdn.
But while we are sorting that out - see if the following helps:

1
2
Rect rect(x_pos, y_pos, x_pos+56, y_pos+56); //create a Rect structure
g.DrawImage((&music, & rect, x_pos, y_pos, 56, 56, UnitPixel, &imgattr);





**Rect is in the Gdiplus namespace - but I think you already have written a using namesace Gdiplus directive **
Last edited on
No luck in the changed code:
1
2
d:\dokumenter\programmering\visual c++\media player\media player\flow_menu.h(139): error C2664: 'Gdiplus::Status Gdiplus::Graphics::DrawImage(Gdiplus::Image *,Gdiplus::REAL,Gdiplus::REAL,Gdiplus::REAL,Gdiplus::REAL,Gdiplus::REAL,Gdiplus::REAL,Gdiplus::Unit)' : cannot convert parameter 2 from 'Gdiplus::Rect *' to 'Gdiplus::REAL'
1>          There is no context in which this conversion is possible


Here is the link for the information: http://msdn.microsoft.com/en-us/library/ms142046.aspx
When I was looking at the GDIplus stuff, that DrawImage function has 16 overloads.
You may need to be a bit more precise in our choice and quantity of parameters.
I choose the overload because I was looking on a tutorial on how to use alphablend with images. He used that function overload.

Link: http://www.codeproject.com/KB/GDI-plus/AlphaBlending.aspx
We can try;


g.DrawImage((&music, & rect, x_pos, y_pos, 56, 56, UnitPixel, &imgattr, NULL, NULL );

I'll look at the link in the meantime
Damn this is anyoing... still complaining :S
You could dump the code on pastebin or something - and the forum could have a look and try to debug it.
Hmm... everything works besides this part. I'm considering changing to another graphic libary with hardware acceleration, unless there is another way to do alpha blending with GDI+?
Topic archived. No new replies allowed.