vfp 如何批量更改照片大小
vfp 如何批量更改照片大小,数码相机照片如何指更改
期待高手出现
一般用第三方软件
*------------------------------------- * 将输入图片转换为透明底PNG格式 * 参数:tcFileName -- 输入图片文件名 * 返回:转换成功为真否则为假 *------------------------------------- FUNCTION Convert_Picture(tcFileName AS Character) AS Boolean LOCAL loSourceBitmap AS Object LOCAL loTargetBitmap AS Object LOCAL loColor AS Object LOCAL loGraphics AS Object IF FILE(tcFileName) loSourceBitmap = NEWOBJECT("gpBitmap", "_GDIplus.vcx") loSourceBitmap.CreateFromFile(tcFileName) loTargetBitmap = NEWOBJECT("gpBitmap", "_GDIplus.vcx") loTargetBitmap.Create(loSourceBitmap.ImageWidth, loSourceBitmap.ImageHeight) loColor = NEWOBJECT("gpColor", "_GDIplus.vcx") loColor.Set(0,0,0,0) && 透明背景 loGraphics = NEWOBJECT("gpGraphics", "_GDIplus.vcx") WITH loGraphics .CreateFromImage(loTargetBitmap) .Clear(loColor) .DrawImageAt(loSourceBitmap, 0, 0) ENDWITH tcFileName = LEFT(tcFileName, LENC(tcFileName) - 3) + "PNG" loTargetBitmap.SaveToFile(tcFileName, "image/png") RETURN .T. ELSE RETURN .F. ENDIF ENDFUNC
*原图片尺寸改变现有的图片尺寸 =resizeimage([f:\yyrj\3.jpg],[f:\yyrj\31.jpg],400,300) Declare INTEGER ShellExecute IN shell32; INTEGER hwnd, STRING lpOperation,; STRING lpFile, STRING lpParameters,; STRING lpDirectory, INTEGER nShowCmd = ShellExecute (0, [open], [f:\yyrj\3.jpg],[],[], 3) && 原图 =INKEY(2) && 等待2秒钟再查看新图 = ShellExecute (0, [open], [f:\yyrj\31.jpg],[],[], 3) && 新图 ******************************************* *算法制作:行者孙(QQ:310727570) ******************************************* FUNCTION resizeimage(pSourceFileNAme as String,pNewFileNAme as String,nWidth as Long,nHeight as long) PRIVATE pSourceFileNAme,pNewFileNAme,nWidth,nHeight DECLARE INTEGER GdiplusStartup IN gdiplus INTEGER @token, STRING @INPUT, INTEGER OUTPUT LOCAL hToken, cInput hToken = 0 cInput = PADR(CHR(1), 16, CHR(0)) GdiplusStartup(@hToken, @cInput, 0) DECLARE INTEGER GdipLoadImageFromFile IN gdiplus.DLL STRING wFilename, INTEGER @nImage LOCAL nImage nImage = 0 GdipLoadImageFromFile(STRCONV(pSourceFileNAme + CHR(0), 5), @nImage) #DEFINE GDIPLUS_PIXELFORMAT_32bppARGB 0x0026200A DECLARE INTEGER GdipCreateBitmapFromScan0 IN gdiplus.DLL ; INTEGER nWidth, INTEGER nHeight, INTEGER nStride; , INTEGER nPixelFormat ; , STRING @ cScan0, INTEGER @ nImage LOCAL nBitmap, nWidth, nHeight, nX, nY nBitmap = 0 nX = 0 nY = 0 GdipCreateBitmapFromScan0(nWidth, nHeight, 0, GDIPLUS_PIXELFORMAT_32bppARGB, 0, @nBitmap) DECLARE INTEGER GdipGetImageGraphicsContext IN gdiplus.DLL ; INTEGER nImage, INTEGER @ nGraphics LOCAL nGraphics nGraphics = 0 GdipGetImageGraphicsContext (nBitmap, @nGraphics) DECLARE INTEGER GdipDrawImageRect IN gdiplus.DLL ; INTEGER nGraphics, INTEGER nImage, SINGLE,SINGLE,SINGLE,SINGLE GdipDrawImageRect(nGraphics, nImage, nX, nY, nWidth, nHeight) LOCAL lcEncoder lcEncoder = REPLICATE(CHR(0),16) DECLARE INTEGER CLSIDFromString IN ole32 STRING lpsz, STRING @pclsid CLSIDFromString(STRCONV("{557CF401-1A04-11D3-9A73-0000F81EF32E}" + CHR(0), 5), @lcEncoder) DECLARE INTEGER GdipSaveImageToFile IN gdiplus.DLL ; INTEGER nImage, STRING wFilename, STRING qEncoder, INTEGER nEncoderParamsPtr ERASE (pNewFileNAme) DECLARE Long GdipDisposeImage IN Gdiplus.dll Long nativeImage GdipDisposeImage(nImage) GdipSaveImageToFile (nBitmap, STRCONV(pNewFileNAme,5) + CHR(0), lcEncoder, 0) DECLARE INTEGER GdiplusShutdown IN gdiplus INTEGER token GdiplusShutdown(hToken) CLEAR DLLS ENDFUNC用于JPEG格式的图片