[英]Resize image function doesn't save anything
Trying to resize an image but the following function I found doesn't produce any outcome. 尝试调整图像大小,但是我发现以下功能不会产生任何结果。 I figure that the function needs to save bitmap to file, so I added that code.. but nothing is saved.
我认为该功能需要将位图保存到文件,因此我添加了该代码..但未保存任何内容。 All ahk files and images are in the same folder.
所有ahk文件和图像都在同一文件夹中。
#Include Gdip.ahk
If !pToken := Gdip_Startup()
{
MsgBox, 48, gdiplus error!, Gdiplus failed to start. Please ensure you have gdiplus on your system
ExitApp
}
pBitmap := "test.bmp"
pResizedBitmap := Gdip_ResizeBitmap(pBitmap, 200, 0)
Gdip_SaveBitmapToFile(pResizedBitmap, "Resize.png")
Gdip_Shutdown(pToken)
MsgBox
Gdip_ResizeBitmap(pBitmap, PercentOrWH, Dispose=1) { ; returns resized bitmap. By Learning one.
Gdip_GetImageDimensions(pBitmap, origW, origH)
if PercentOrWH contains w,h
{
RegExMatch(PercentOrWH, "i)w(\d*)", w), RegExMatch(PercentOrWH, "i)h(\d*)", h)
NewWidth := w1, NewHeight := h1
NewWidth := (NewWidth = "") ? origW/(origH/NewHeight) : NewWidth
NewHeight := (NewHeight = "") ? origH/(origW/NewWidth) : NewHeight
}
else
NewWidth := origW*PercentOrWH/100, NewHeight := origH*PercentOrWH/100
pBitmap2 := Gdip_CreateBitmap(NewWidth, NewHeight)
G2 := Gdip_GraphicsFromImage(pBitmap2), Gdip_SetSmoothingMode(G2, 4), Gdip_SetInterpolationMode(G2, 7)
Gdip_DrawImage(G2, pBitmap, 0, 0, NewWidth, NewHeight)
Gdip_DeleteGraphics(G2)
if Dispose
Gdip_DisposeImage(pBitmap)
return pBitmap2
}
Any help would be much appreciated! 任何帮助将非常感激!
pBitmap := "test.bmp"
Won't work. 不行 You have to invoke
Gdip_CreateBitmapFromFile()
function from Gdip library to create pointer to bitmap. 您必须从Gdip库调用
Gdip_CreateBitmapFromFile()
函数来创建指向位图的指针。 In example 6 you can see it being used. 在示例6中,您可以看到它的使用。
Like that (the rest should work): 这样(其余的应该工作):
pBitmap := Gdip_CreateBitmapFromFile("test.bmp")
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.