closed
Joined: 07 Feb 2008 Posts: 509
|
Posted: Tue Mar 02, 2010 8:18 pm Post subject: |
|
|
Creating a canvas that is 60pixels larger than the image and centering the image on it?
| Code: |
#SingleInstance, Force
#NoEnv
SetBatchLines, -1
#Include, Gdip.ahk
FileSelectFile, file1
If !pToken := Gdip_Startup()
{
MsgBox, 48, gdiplus error!, Gdiplus failed to start. Please ensure you have gdiplus on your system
ExitApp
}
pBitmapFile1 := Gdip_CreateBitmapFromFile(File1)
Width := Gdip_GetImageWidth(pBitmapFile1), Height := Gdip_GetImageHeight(pBitmapFile1)
w:=width+60
h:=height+60
pBitmap := Gdip_CreateBitmap(w, h)
G := Gdip_GraphicsFromImage(pBitmap)
pBrush := Gdip_BrushCreateSolid(0xffffffff)
Gdip_FillRectangle(G, pBrush, 0, 0, w, h)
Gdip_DeleteBrush(pBrush)
Gdip_DrawImage(G, pBitmapFile1, 30, 30, Width, Height, 0, 0, Width, Height)
Gdip_DisposeImage(pBitmapFile1)
Gdip_SaveBitmapToFile(pBitmap, "FinalImage.png")
Gdip_DisposeImage(pBitmap)
Gdip_DeleteGraphics(G)
Gdip_Shutdown(pToken)
ExitApp
Return |
|
|