关于JPG图片大小转换
现公司有一需求:要求将类型为JPG的图片由1200*1600转换为300*350,
要求能同时转多个JPG文档
不能用ACDC,PS等转换工具,要求自已用VB6写代码
请问如何做到?
1.能否提供算法或相关免费的DLL调用
2.如果上面的没有办法提供,发几个URL参考下,多谢
Option Explicit
Private Declare Function StretchBlt Lib "gdi32" (ByVal hdc As Long, _
ByVal x As Long, _
ByVal y As Long, _
ByVal nWidth As Long, _
ByVal nHeight As Long, _
ByVal hSrcDC As Long, _
ByVal xSrc As Long, _
ByVal ySrc As Long, _
ByVal nSrcWidth As Long, _
ByVal nSrcHeight As Long, _
ByVal dwRop As Long) As Long
Private Sub Command1_Click()
Dim lngP As Long
lngP = StretchBlt(Picture2.hdc, 0, 0, Picture2.ScaleWidth, Picture2.ScaleHeight, Picture1.hdc, 0, 0, Picture1.ScaleWidth, Picture1.ScaleHeight, vbSrcCopy)
If lngP <> 0 Then SavePicture Picture2.Image, "D:\2.bmp"
End Sub
Private Sub Form_Load()
Me.ScaleMode = 3
Picture1.AutoRedraw = True
Picture2.AutoRedraw = True
Picture2.Width = 0.5 * Picture1.Width
Picture2.Height = 0.5 * Picture1.Height
Picture1.Picture = LoadPicture("D:\1.bmp")
End Sub
这只是个例子,给你提供一个思路。通过stretchblt可以修改图片的大小。也就是分辨率。 得再使用GDI将 .bmp转换为 .jpg 或尺寸转变时直接使用GDI保存为.jpg
恩恩 图片缩放是基本功,掌握相关的API不难。 直接使用GDI+吧一下就搞定了 数字图像处理
补充:VB , 多媒体