IonicWind Software

IWBasic => Games and Graphics => Topic started by: TonyMUK on June 18, 2010, 02:26:56 AM

Title: Image resize
Post by: TonyMUK on June 18, 2010, 02:26:56 AM
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
Title: Re: Image resize
Post by: sapero on June 18, 2010, 02:51:42 AM
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)
Title: Re: Image resize
Post by: TonyMUK on June 18, 2010, 05:22:44 AM
Thanks Sapero. I had got mixed up with pointers again.

TonyM