April 16, 2024, 04:09:23 AM

News:

IonicWind Snippit Manager 2.xx Released!  Install it on a memory stick and take it with you!  With or without IWBasic!


Image resize

Started by TonyMUK, June 18, 2010, 02:26:56 AM

Previous topic - Next topic

0 Members and 1 Guest are viewing this topic.

TonyMUK

I am trying to resize an image in my program. The user enters the new width and height they want the image to be. The solution I found was to use GDI+ but I keep getting the error "no appropriate conversion exists" on the GetImageThumbnail line. NewWidth and NewHeight are both defined as UINT. The Content part of UserControls holds the file path and name. Does anyone know why I am getting the error or if there is an easier/better way to achieve the result I need.

Thanks

TonyM


Sub ChangeImageSize

Pointer Image, NewImage

Error = GdipLoadImageFromFile(UserControls[ControlNumber].Content, Image)
Error = gdipGetImageThumbnail(Image,NewWidth,NewHeight,Image,0,0)
Error = gdipSaveImageToFile(NewImage,UserControls[ControlNumber].Content,ImageEncoderJpeg,0)

EndSub
Check out www.arnoldchiari.co.uk. If you don't know what Arnold Chiari is you are very lucky.

sapero

Hi Tony, probably you have included not the top-level headers.
Anyway you have bugs - passing a pointer value where pointer address should be.

This is a dummmy code to just check if it compiles:
$include "windowssdk.inc"
$include "gdiplus.inc"

Pointer Image, NewImage
UINT NewWidth,NewHeight
pointer UnicodePath '= UserControls[ControlNumber].Content

GdipLoadImageFromFile(UnicodePath, &Image/*retval*/)
GdipGetImageThumbnail(Image,NewWidth,NewHeight,&NewImage/*retval*/,0,0)
GdipSaveImageToFile(NewImage, UnicodePath, ImageEncoderJpeg,0)
'delete images
GdipDisposeImage(NewImage)
GdipDisposeImage(Image)

TonyMUK

Thanks Sapero. I had got mixed up with pointers again.

TonyM
Check out www.arnoldchiari.co.uk. If you don't know what Arnold Chiari is you are very lucky.