|
-
Jan 7th, 2020, 02:20 PM
#1
Thread Starter
Addicted Member
[RESOLVED] GDI+ problems with GdipDrawImageRectRectI
Hi Guys!
I'm creating a windowless usercontrol and have 2 functions to draw an image I load with GdipLoadImageFromFile.
A) calls GdipDrawImageRectI gdipGraphics, img, x, y, x2, y2
and works perfectly!!!
B) calls GdipDrawImageRectRectI gdipGraphics, img, x, y, x2, y2, 0, 0, Width&, Height&, 2
and dont draw anything...
Cause A) works fine I know gdipGraphics and img are not the problem. The values of x,y are 0,0 and x2,y2 are the same as width and height of the image (also tested other values, no change)
What can be the cause of problem ? I'm really stuck with this
-
Jan 7th, 2020, 03:03 PM
#2
Re: GDI+ problems with GdipDrawImageRectRectI
Why the second "Rect" in the second method name call? e.g. Why GdipDrawImageRectRectI vs. GdipDrawImageRectI?
-
Jan 7th, 2020, 03:16 PM
#3
Thread Starter
Addicted Member
Re: GDI+ problems with GdipDrawImageRectRectI
 Originally Posted by jpbro
Why the second "Rect" in the second method name call? e.g. Why GdipDrawImageRectRectI vs. GdipDrawImageRectI?
These are the declarations:
A) Private Declare Function GdipDrawImageRectI Lib "GdiPlus.dll" (ByVal graphics As Long, ByVal img As Long, ByVal x As Long, ByVal y As Long, ByVal Width As Long, ByVal Height As Long) As Long
B) Private Declare Function GdipDrawImageRectRectI Lib "gdiplus" (ByVal hGraphics As Long, ByVal hImage As Long, ByVal dstX As Single, ByVal dstY As Single, ByVal dstWidth As Single, ByVal dstHeight As Single, ByVal srcX As Single, ByVal srcY As Single, ByVal srcWidth As Single, ByVal srcHeight As Single, Optional ByVal srcUnit As Long = 2, Optional ByVal hImageAttributes As Long, Optional ByVal pfnCallback As Long, Optional ByVal lCallbackData As Long) As Long
I asume the first take an image and draw it COMPLETELY at the x,y point with a size of widht and height (auto shrinking/enlarging) and the second can take JUST A PART of the image and draw it in the same way and optionally applying effects (wich is why I need it) but I'm failing to make it work without adding any effects at all.
-
Jan 7th, 2020, 03:29 PM
#4
Re: GDI+ problems with GdipDrawImageRectRectI
The first takes 32-bit integers as input.
The second takes 32-bit floats as input.
Are you using Singles when you do the second call?
"Anyone can do any amount of work, provided it isn't the work he is supposed to be doing at that moment" Robert Benchley, 1930
-
Jan 7th, 2020, 03:40 PM
#5
Thread Starter
Addicted Member
Re: [RESOLVED] GDI+ problems with GdipDrawImageRectRectI
Sorry guys!!! The problem was between the chair and the monitor .... I tried to test the drawing part before adding the color/alpha effects and commented too much of the code. I need to sleep more! Sorry
-
Jan 7th, 2020, 03:45 PM
#6
Re: GDI+ problems with GdipDrawImageRectRectI
Is that declaration correct?
I've seen GdipDrawImageRectRectI for PowerBasic declared as follows:
Code:
DECLARE FUNCTION GdipDrawImageRectRectI ( _
BYVAL graphics AS DWORD, _
BYVAL pImage AS DWORD, _
BYVAL dstx AS LONG, _
BYVAL dsty AS LONG, _
BYVAL dstwidth AS LONG, _
BYVAL dstheight AS LONG, _
BYVAL srcx AS LONG, _
BYVAL srcy AS LONG, _
BYVAL srcwidth AS LONG, _
BYVAL srcheight AS LONG, _
BYVAL srcUnit AS LONG, _
BYVAL imageAttributes AS DWORD, _
BYVAL pcallback AS DWORD, _
BYVAL callbackData AS DWORD _
) AS LONG
I would assume there could be a similar declaration for a VB6 version. I haven't used Gdip... with vb6, so my only real experience with GDI+ is with the wrapped versions of the calls as part of .Net.
"Anyone can do any amount of work, provided it isn't the work he is supposed to be doing at that moment" Robert Benchley, 1930
-
Jan 7th, 2020, 03:54 PM
#7
Re: [RESOLVED] GDI+ problems with GdipDrawImageRectRectI
If you just need to provide attributes, and don't need to scale the drawing into a destination rectangle, then there should be a slightly simpler call, if all the versions of DrawImage are implemented in Gdip, i.e. you provide dstX and dstY, but no dstWidth or Height. And there should be a Long parameter types version as well as the Single parameter types version.
Again, not familiar with implementation in VB6, so perhaps all the variations of DrawImage are not mapped.
Also, using the non-scaling destination version you would think would draw faster.
"Anyone can do any amount of work, provided it isn't the work he is supposed to be doing at that moment" Robert Benchley, 1930
-
Jan 7th, 2020, 04:06 PM
#8
Thread Starter
Addicted Member
Re: [RESOLVED] GDI+ problems with GdipDrawImageRectRectI
 Originally Posted by passel
If you just need to provide attributes, and don't need to scale the drawing into a destination rectangle, then there should be a slightly simpler call, if all the versions of DrawImage are implemented in Gdip, i.e. you provide dstX and dstY, but no dstWidth or Height. And there should be a Long parameter types version as well as the Single parameter types version.
Again, not familiar with implementation in VB6, so perhaps all the variations of DrawImage are not mapped.
Also, using the non-scaling destination version you would think would draw faster.
Thanks for answering. That's why i have 2 functions to draw. When no need for effects and one when needed (greyscale image when disabled for example). I will use it mainly for data forms so Speed is not much important and GDI+ is fast enough. There is no much redrawing until buttons change for some reason.
Last edited by shagratt; Jan 7th, 2020 at 04:14 PM.
-
Jan 7th, 2020, 04:22 PM
#9
Thread Starter
Addicted Member
Re: GDI+ problems with GdipDrawImageRectRectI
 Originally Posted by passel
The first takes 32-bit integers as input.
The second takes 32-bit floats as input.
Are you using Singles when you do the second call?
Yes! That was the problem!!!
The weird part is I fixed it calling GdipDrawImageRect (wich require singles) and passing long values... After your suggestion I fixed my declarations to long (the one I copied where from another example and not the ones I was using) and put back GdipDrawImageRectI
-
Jan 7th, 2020, 05:55 PM
#10
Re: [RESOLVED] GDI+ problems with GdipDrawImageRectRectI
https://github.com/javiercrowsoft/ca...modGDIPlus.bas
This is a fairly complete list of declares of the flat GDI+ API I'm "borrowing from" usually. Note that there are a few declares missing and a few errors but these are very few (newer API).
cheers,
</wqw>
-
Jan 7th, 2020, 09:52 PM
#11
Thread Starter
Addicted Member
Re: [RESOLVED] GDI+ problems with GdipDrawImageRectRectI
 Originally Posted by wqweto
Thanks wqw! I usually try to not add this super definition files and keep adding every call on demand just to learn more of their usage and existence. I used 'helpers' in past and that's the main reason why sadly I still feel very 'green' about GDI+ usage. I'm being a little philanthropic lately and spend lot of time reinventing the wheel just to learn a little more every day.
Tags for this Thread
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
|