📜  vfp 裁剪图像 - 任何代码示例

📅  最后修改于: 2022-03-11 14:57:31.500000             🧑  作者: Mango

代码示例1
LOCAL lcSource      lcSource = GETPICT()IF EMPTY(lcSource)          RETURN      ENDIF * Load image to GDI+       LOCAL loImage AS gpImage OF HOME() + ffc/_gdiplus.vcx      loImage = NEWOBJECT("gpImage",HOME()+"ffc/_gdiplus.vcx")      loImage.CreateFromFile(lcSource)      lnWidth = loImage.ImageWidth      lnHeight = loImage.ImageHeight  * Crop Image
LOCAL loCropped as gpBitmap OF HOME() + ffc/_gdiplus.vcx* Crop TopLeft       loCropped = Crop(loImage, 0, 0, lnWidth / 2, lnHeight /2)      loCropped.SavetoFile("crop-topleft.png","image/png")      RUN /n Explorer.exe crop-topleft.png* Crop BottomRight       loCropped = Crop(loImage, lnWidth / 2, lnHeight /2, lnWidth /2, lnHeight /2)loCropped.SavetoFile("crop-bottomright.png","image/png")      RUN /n Explorer.exe crop-bottomright.png* CropCenter      loCropped = Crop(loImage, lnWidth / 4, lnHeight /4, lnWidth /2, lnHeight /2)loCropped.SavetoFile("crop-center.png","image/png")      RUN /n Explorer.exe crop-center.pngRETURN  PROCEDURE Crop(toImage, x, y, tnWidth, tnHeight, tnPixelFormat)        IF VARTYPE(tnPixelFormat) = "l"           tnPixelFormat = toImage.PixelFormat        ENDIF * gpstatus wingdipapi gdipclonebitmapareai         * (int x, int y, int width, int height, pixelformat format,          * gpbitmap *srcbitmap, gpbitmap **dstbitmap)          DECLARE LONG gdipclonebitmapareai IN gdiplus.dll ;           LONG x, LONG y, LONG nwidth, LONG nheight, ;           LONG pixelformat, LONG srcbitmap, LONG @dstbitmap        LOCAL lnNewBitmap        lnNewBitmap = 0        = gdipCloneBitmapAreaI(x, y, tnWidth, tnHeight, ;        tnPixelFormat, toImage.getHandle(), @lnNewBitmap)        LOCAL loNewImage        loNewImage = NEWOBJECT("gpBitmap",HOME()+"ffc/_gdiplus.vcx")        loNewImage.SetHandle(lnNewBitmap)        RETURN lonewimage        ENDPROC