[quote="Safeguard"][/quote]
Code:
GDIplusError:
MsgBox, SOMETHING IS WRONG
Return
...OMFG!...WORST...ERROR...MESSAGE...EVER!!!...come on!...how do you expect to debug it with THAT error message?...I haven't even looked into this script & I'm gonna guess what I think'll work...
Code:
#Include GDIplusWrapper.ahk
;//HERE ARE THE FILENAMES!!!
;//fileNameOrig=OriginalImage.png
File_Src=Image-Src.png
Random, r, 1000000, 9999999
;//fileNameDestP=ResultImage.png
File_Dest=Image-Dest-%r%.png
;//File_Dest=%A_Temp%\Image-Dest-%r%.png
;//comment out to keep same size
File_Dest_w:=125
File_Dest_h:=125
;//File_Dest_scalew:=.4
;//File_Dest_scaleh:=.4
;//File_Dest_h:=ceil(thumb_w*A_ScreenHeight/A_ScreenWidth) ;//keep screenratio
;//wtf does this mean?...anti-alias?
;//use_antialize:=1
;//renamed to...
;//Use_HALFTONE=1
;//wtf does this do?...dumb name...
;//noParams=NONE
encoderParams=None
;//---------------------------------------
;//TRYING TO LOAD MY ORIGINAL IMAGE IN HERE
;//
;//WHAT DO I NEED TO GET ANY IMAGE TYPE INPUTTED HERE? PNG/JPG/GIF :)
step=GDIplus_Start
if (GDIplus_Start()!=0)
Goto, GDIplusError
;//Load image
step=GDIplus_LoadImage
if (GDIplus_LoadImage(hw_frame, File_Src)!=0)
Goto, GDIplusError
GDIplus_GetImageDimension(hw_frame, File_Src_w, File_Src_h)
msgbox, 64, ,
(LTrim
File_Src_w(%File_Src_w%) File_Src_h(%File_Src_h%)
File_Dest_w(%File_Dest_w%) File_Dest_h(%File_Dest_h%)
)
;//---------------------------------------
if (File_Dest_w="") {
File_Dest_w:=File_Src_w
if (File_Dest_scalew)
File_Dest_w*=File_Dest_scalew
}
if (File_Dest_h="") {
File_Dest_h:=File_Src_h
if (File_Dest_scaleh)
File_Dest_h*=File_Dest_scaleh
}
if (File_Src_w!=File_Dest_w || File_Src_h!=File_Dest_h) {
if (method="" || method="GDI+") {
;//GdipGetImageThumbnail(
;// GpImage *image, UINT thumbWidth, UINT thumbHeight,
;// GpImage **thumbImage, GetThumbnailImageAbort callback, VOID * callbackData)
DllCall("GDIplus\GdipGetImageThumbnail"
, "UInt", bitmap, "UInt", File_Dest_w, "UInt", File_Dest_h
, "UInt", bitmap_thumb, "UInt", 0, "UInt", 0)
} else if (method="StretchBlt") {
msgbox, 16, , StretchBlt NOT IMPLEMENTED YET!
return
;// *** Note: this code won't work, it's not cleaned up yet!
hdc_frame:=DllCall("GetDC", "UInt", hw_frame)
;///hdc_frame_full:=DllCall("GetDC", "UInt", hw_frame)
;//buffer
hdc_buffer:=DllCall("gdi32.dll\CreateCompatibleDC", "UInt", hdc_frame)
hbm_buffer:=DllCall("gdi32.dll\CreateCompatibleBitmap" , "UInt", hdc_frame, "Int", thumb_w, "Int", thumb_h)
r:=DllCall("gdi32.dll\SelectObject", "UInt", hdc_buffer, "UInt", hbm_buffer)
;///hdc_buffer_full:=DllCall("gdi32.dll\CreateCompatibleDC", "UInt", hdc_frame_full)
;///hbm_buffer_full:=DllCall("gdi32.dll\CreateCompatibleBitmap" , "UInt", hdc_frame_full, "Int", A_ScreenWidth, "Int", A_ScreenHeight)
;///r_full:=DllCall("gdi32.dll\SelectObject", "UInt", hdc_buffer_full, "UInt", hbm_buffer_full)
;//comment this line for speed but less quality
;//if (use_antialize=1) {
if (Use_HALFTONE=1) {
;//Halftone better quality with stretch
HALFTONE=4
DllCall("gdi32.dll\SetStretchBltMode", "UInt", hdc_buffer, "Int", HALFTONE)
}
if (GDIplus_Start()!=0)
Goto, GDIplusError
;//---- IS THIS STEP NECESSARY? WANT BEST QUALITY
;//Copy BMP from DC
;//Damn it!...don't use magic numbers...use vars!!!...like this...
SRCCOPY:=0x00CC0020
DllCall("gdi32.dll\StretchBlt"
, "UInt", hdc_buffer, "Int", 0, "Int", 0, "Int", thumb_w, "Int", thumb_h
, "UInt", hdc_frame, "Int", 0, "Int", 0, "Int", A_ScreenWidth, "Int", A_ScreenHeight, "UInt", SRCCOPY)
DllCall("GDIplus\GdipCreateBitmapFromHBITMAP", "UInt", hbm_buffer, "UInt", 0, "UIntP", bitmap_thumb)
DllCall("gdi32.dll\DeleteObject", "UInt", hbm_buffer)
DllCall("gdi32.dll\DeleteDC", "UInt", hdc_frame)
DllCall("gdi32.dll\DeleteDC", "UInt", hdc_buffer)
}
}
;//Save to PNG
if (GDIplus_GetEncoderCLSID(pngEncoder, "image/png")!=0)
Goto, GDIplusError
if (GDIplus_SaveImage(bitmap_thumb, File_Dest, pngEncoder, encoderParams)!=0)
Goto, GDIplusError
GDIplus_Stop()
return
GDIplusError:
msgbox, SOMETHING IS WRONG...really helpful error huh?
return
...ok sorry that's not tested...I'll test it later...