« | April 2021 | » | 日 | 一 | 二 | 三 | 四 | 五 | 六 | | | | | 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | 20 | 21 | 22 | 23 | 24 | 25 | 26 | 27 | 28 | 29 | 30 | | |
| 公告 |
暂无公告... |
Blog信息 |
blog名称:VFP及Sql Server拙笔 日志总数:46 评论数量:107 留言数量:0 访问次数:403848 建立时间:2005年5月12日 |

| |
[编程及数据库]VFP9利用_GdiPlus类处理图片分辨率及缩放 原创空间, 随笔, 心得体会, 事件记录, 软件技术, 电脑与网络
老瓷 发表于 2015/2/7 14:39:14 |
Local lcFile_S, lcFile_T, lnW_T, lnH_T, lnXDpi_T, lnYDpi_T
m.lcFile_S = 'D:\Temp\Source.jpg'm.lcFile_T = 'D:\Temp\Target.jpg'
m.lnW_T = 160 && 目标图宽、高度m.lnH_T = 240m.lnXDpi_T = 72 && 目标图分辨率m.lnYDpi_T = 72
Set Classlib To "_GDIPlus.Vcx" Additive
oGraphics=CreateObject("gpGraphics") && 创建工作图像
oImage=CreateObject("gpImage") && 源图oImage.CreateFromFile(m.lcFile_S) && 从源图创建m.lnW = oImage.ImageWidth && 宽m.lnH = oImage.ImageHeight && 高m.lnXDpi = oImage.HorizontalResolution && 水平分辨率m.lnYDpi = oImage.VerticalResolution && 垂直分辨率
oBitMap=CreateObject("gpBitMap") && 目标图oBitMap.Create(m.lnW_T, m.lnH_T) && 按目标图大小创建
oGraphics.CreateFromImage(oBitMap) && 工作图像按目标图建立oBitMap.SetResolution(m.lnXDpi_T, m.lnYDpi_T) && 设置目标图分辨率
oGraphics.DrawImageScaled(oImage, 0, 0, m.lnW_T, m.lnH_T) && 源图按指定矩形区域缩放
m.lnQuality = 90 && 100 && 图片保存质量oBitMap.SaveToFile(m.lcFile_T, oImage.GetEncoderCLSID("image/jpeg"), "quality="+Transform(m.lnQuality)) && 按源文件类型保存至目标文件
Release oBitMap && 释放Release oImageRelease oGraphics
Release Classlib _GdiPlus |
|
|