Results 1 to 11 of 11

Thread: [RESOLVED] GDI+ problems with GdipDrawImageRectRectI

  1. #1

    Thread Starter
    Addicted Member shagratt's Avatar
    Join Date
    Jul 2019
    Location
    Argentina
    Posts
    203

    Resolved [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

  2. #2
    PowerPoster
    Join Date
    Aug 2010
    Location
    Canada
    Posts
    2,892

    Re: GDI+ problems with GdipDrawImageRectRectI

    Why the second "Rect" in the second method name call? e.g. Why GdipDrawImageRectRectI vs. GdipDrawImageRectI?

  3. #3

    Thread Starter
    Addicted Member shagratt's Avatar
    Join Date
    Jul 2019
    Location
    Argentina
    Posts
    203

    Re: GDI+ problems with GdipDrawImageRectRectI

    Quote Originally Posted by jpbro View Post
    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.

  4. #4
    Sinecure devotee
    Join Date
    Aug 2013
    Location
    Southern Tier NY
    Posts
    6,598

    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

  5. #5

    Thread Starter
    Addicted Member shagratt's Avatar
    Join Date
    Jul 2019
    Location
    Argentina
    Posts
    203

    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

  6. #6
    Sinecure devotee
    Join Date
    Aug 2013
    Location
    Southern Tier NY
    Posts
    6,598

    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

  7. #7
    Sinecure devotee
    Join Date
    Aug 2013
    Location
    Southern Tier NY
    Posts
    6,598

    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

  8. #8

    Thread Starter
    Addicted Member shagratt's Avatar
    Join Date
    Jul 2019
    Location
    Argentina
    Posts
    203

    Re: [RESOLVED] GDI+ problems with GdipDrawImageRectRectI

    Quote Originally Posted by passel View Post
    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.

  9. #9

    Thread Starter
    Addicted Member shagratt's Avatar
    Join Date
    Jul 2019
    Location
    Argentina
    Posts
    203

    Re: GDI+ problems with GdipDrawImageRectRectI

    Quote Originally Posted by passel View Post
    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

  10. #10
    PowerPoster wqweto's Avatar
    Join Date
    May 2011
    Location
    Sofia, Bulgaria
    Posts
    6,167

    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>

  11. #11

    Thread Starter
    Addicted Member shagratt's Avatar
    Join Date
    Jul 2019
    Location
    Argentina
    Posts
    203

    Re: [RESOLVED] GDI+ problems with GdipDrawImageRectRectI

    Quote Originally Posted by wqweto View Post
    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>
    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
  •  



Click Here to Expand Forum to Full Width