oListener = CREATEOBJECT('reportlistener') && Instanciate GDI class oImage= newobject('GpBitmap','ffc/_gdiplus.vcx') && Create an instance of an image oImage.CreateFromFile(GETPICT()) && Load the image to be reduced oImg=oListener.GetThumbnailImage(100,100) && Reduce the image to 100X100 oImg.SaveToFile('c:\image2.jpg',"image/jpeg",'quality=80')>I'm trying to use the GDI + FFC classes in VFP 9 to resize an image but it keeps writing out an empty file. GetErrorStatus() returns .F., but the SaveToFile() call is returning .F.. Similar code in .NET works just fine. None of the other calls seems to fail.
>#define GDIPLUS_QualityMode_High 2 && Best rendering quality >#define GDIPLUS_InterpolationMode_HighQualityBicubic 7 >#define GDIPLUS_PixelOffsetMode_HighQuality GDIPLUS_QualityMode_High >#define GDIPLUS_IMAGEFORMAT_JPEG 0hAE3C6BB92807D3119D7B0000F81EF32E > >#define GDIPLUS_SmoothingMode_HighQuality GDIPLUS_QualityMode_High > >loGraphics = CREATEOBJECT("gpGraphics") >loBMP = CREATEOBJECT("gpBitmap") > >loImage = CREATEOBJECT("gpImage") >loImage.CreateFromFile("C:\Sample.JPG") > >lnHeight = loImage.ImageHeight >lnWidth = loImage.ImageWidth >lnMaxSize = 100 > >IF lnWidth > lnHeight > * Wider than height > lnScale = lnWidth / lnMaxSize > lnWidth = lnMaxSize > lnHeight = INT(ROUND(lnHeight / lnScale, 0)) >ELSE > * Taller than width > lnScale = lnHeight / lnMaxSize > lnHeight = lnMaxSize > lnWidth = INT(ROUND(lnWidth / lnScale, 0)) >ENDIF > >?loBMP.Create(lnWidth, lnHeight, loImage.PixelFormat) > >?loGraphics.CreateFromImage(loBMP) >loGraphics.SmoothingMode = GDIPLUS_SmoothingMode_HighQuality >loGraphics.InterpolationMode = GDIPLUS_InterpolationMode_HighQualityBicubic >loGraphics.PixelOffsetMode = GDIPLUS_PixelOffsetMode_HighQuality > >?loGraphics.DrawImageScaled(loImage, 0, 0, lnWidth, lnHeight) > >IF !loBMP.SaveToFile("C:\testimg.JPG", GDIPLUS_IMAGEFORMAT_JPEG) > ?loBMP.GetErrorStatus() > MESSAGEBOX(loBMP.GetLastErrorMessage()) >ENDIF >