CodeGuru Home VC++ / MFC / C++ .NET / C# Visual Basic VB Forums Developer.com
Results 1 to 5 of 5
  1. #1
    Join Date
    Apr 2004
    Posts
    204

    [gdi+] DrawImage to specified size

    I am trying to draw a bitmap on the screen 1" X 1.5" using this code:

    Code:
        status = GdipDrawImageRectRect(graphics, image, _
                                       0, 0, 1, 1.5 , _
                                       0, 0, 192, 288, _
                                       UnitPixel)
    The image draws correctly but draws to 1.3"X2"

    What am I doing wrong?

  2. #2
    Join Date
    Feb 2002
    Posts
    4,640

    Re: [gdi+] DrawImage to specified size

    Maybe try specifying UnitInch instead of 'UnitPixel'?

    Viggy

  3. #3
    Join Date
    Apr 2004
    Posts
    204

    Re: [gdi+] DrawImage to specified size

    Thanks for the suggestion.

    I tried that; I get an error when GdipDrawImageRectRect executes
    (and obviously nothing gets drawn).

  4. #4
    Join Date
    Feb 2002
    Posts
    4,640

    Re: [gdi+] DrawImage to specified size

    I'm not all that familiar with the GDI+ functions (anymore, it's been a while since I played around with them). Post the error, perhaps someone else can help.

    Viggy

  5. #5
    Join Date
    Apr 2004
    Posts
    204

    Re: [gdi+] DrawImage to specified size

    If I set the last parameter of the GdipDrawImageRectRect function to UnitInch I get a Not Implemented error

    If I do as below I get proper drawing except not to the specified dimension (want 1" X 1.5" get 1.3" X 2").
    Code:
    status = GdipSetPageUnit(graphics, UnitInch)
    status = GdipDrawImageRectRect(graphics, image, _
                                   0, 0 1, 1.5, _
                                   0, 0, 192, 288, _
                                   UnitPixel)
    It is always out by a constant factor.
    If I adjust to accomodate for this by multiplying by 72 / 96 as below it works properly.
    Code:
    status = GdipSetPageUnit(graphics, UnitInch)
    status = GdipDrawImageRectRect(graphics, image, _
                                   0, 0, 1 * 72 / 96, 1.5 * 72 / 96, _
                                   0, 0, 192, 288, _
                                   UnitPixel)
    ...but I don't understand the significance of * 72 / 96

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

Featured