Jump to content

Resize Picture with GDI+


charvi
 Share

Recommended Posts

Hi Autoiters,

So far I am able to draw pictures (real huge photos) with GDI+:

_GDIPlus_GraphicsDrawImage($h_DTHdc,$h_DTImage,0,0)

but how can I resize the picture while plotting it on the screen? I know the picture's dimensions:

$i_Width =  _GDIPlus_ImageGetWidth ($h_DTImage)
$i_Height = _GDIPlus_ImageGetHeight($h_DTImage)

The _GDIPlus_GraphicsDrawImage() function contains X and Y coordinates, but no W and H... (width & height)

Link to comment
Share on other sites

Easy enough. _GDIPlus_GraphicsDrawImageRect() :)

Thanks monoceres, but this is not what I am asking for. I'm asking how to reduce the image, while _GDIPlus_GraphicsDrawImageRect() just draws a rectangle, and the image is not being reduced to the rectangle size! :)

I have a picture that is 1354x900 large and would like to reduce it to fit a rectangular zone of 800x600.

Link to comment
Share on other sites

Thanks monoceres, but this is not what I am asking for. I'm asking how to reduce the image, while _GDIPlus_GraphicsDrawImageRect() just draws a rectangle, and the image is not being reduced to the rectangle size! :)

I have a picture that is 1354x900 large and would like to reduce it to fit a rectangular zone of 800x600.

I don't understand what you mean, if you want to draw a picture at another size it is _GDIPlus_GraphicsDrawImageRect() you need, if that's not it then you need to explain further what it is you really want.
Link to comment
Share on other sites

I don't understand what you mean, if you want to draw a picture at another size it is _GDIPlus_GraphicsDrawImageRect() you need, if that's not it then you need to explain further what it is you really want.

Yes, what I want is to draw a picture at another size, but I don't see how to achieve this with _GDIPlus_GraphicsDrawImageRect().

With other words, I would like to show thumbnails of my pictures on the screen. A thumbnail that is not larger than, say 200x200 pixels. Of course, the picture should not lose its aspect ratio, unless otherwise specified.

This is my script, the image should fit a zone of 300x150 :

_GDIPlus_GraphicsDrawRect($h_DT_Hdc, 5, 62, 300, 150, $h_DT_Pen)
_GDIPlus_GraphicsDrawImage($h_DT_Hdc,$h_DT_Image,0,0)

I don't understand how to show a thumbnail of the image with a function that just draws a rectangle only. If I use this, the picture

Help file for _GDIPlus_GraphicsDrawRect() says:

_GDIPlus_GraphicsDrawRect

----------------------------------------------------------------------------------------------------

Draw a rectangle

----------------------------------------------------------------------------------------------------

#Include <GDIPlus.au3>

_GDIPlus_GraphicsDrawRect($hGraphics, $iX, $iY, $iWidth, $iHeight[, $hPen = 0])

----------------------------------------------------------------------------------------------------

Parameters

$hGraphics Handle to a Graphics object

$iX The X coordinate of the upper left corner of the rectangle

$iY The Y coordinate of the upper left corner of the rectangle

$iWidth The width of the rectangle

$iHeight The height of the rectangle

$hPen Handle to a pen object that is used to draw the rectangle. If 0, a solid black pen with a width of 1 will be used

Link to comment
Share on other sites

You're looking at the wrong function. I said _GDIPlus_GraphicsDrawImageRect not _GDIPlus_GraphicsDrawRect

Fascinating...

Indeed I used the wrong function. That's the problem with huge function names which have many ressemblence with other functions...

Anyway, thank you for your great help. Now my problem is solved.

Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
 Share

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...