Skip to content

Commit

Permalink
use explicit type checking
Browse files Browse the repository at this point in the history
v2 now throws exceptions as of v2-a95

from:
https://autohotkey.com/boards/viewtopic.php?f=37&t=48965
  • Loading branch information
mmikeww committed May 16, 2018
1 parent ddfebba commit 7575c88
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 6 deletions.
12 changes: 9 additions & 3 deletions Gdip_All.ahk
Expand Up @@ -346,7 +346,7 @@ Gdip_BitmapFromScreen(Screen:=0, Raster:="")
_x := _y := 0 _x := _y := 0
hhdc := GetDCEx(Screen, 3) hhdc := GetDCEx(Screen, 3)
} }
else if (Screen&1 != "") else if IsInteger(Screen)
{ {
M := GetMonitorInfo(Screen) M := GetMonitorInfo(Screen)
_x := M.Left, _y := M.Top, _w := M.Right-M.Left, _h := M.Bottom-M.Top _x := M.Left, _y := M.Top, _w := M.Right-M.Left, _h := M.Bottom-M.Top
Expand Down Expand Up @@ -1206,7 +1206,7 @@ Gdip_DrawImagePointsRect(pGraphics, pBitmap, Points, sx:="", sy:="", sw:="", sh:
NumPut(Coord[1], PointF, 8*(A_Index-1), "float"), NumPut(Coord[2], PointF, (8*(A_Index-1))+4, "float") NumPut(Coord[1], PointF, 8*(A_Index-1), "float"), NumPut(Coord[2], PointF, (8*(A_Index-1))+4, "float")
} }


if (Matrix&1 = "") if !IsNumber(Matrix)
ImageAttr := Gdip_SetImageAttributesColorMatrix(Matrix) ImageAttr := Gdip_SetImageAttributesColorMatrix(Matrix)
else if (Matrix != 1) else if (Matrix != 1)
ImageAttr := Gdip_SetImageAttributesColorMatrix("1|0|0|0|0|0|1|0|0|0|0|0|1|0|0|0|0|0|" Matrix "|0|0|0|0|0|1") ImageAttr := Gdip_SetImageAttributesColorMatrix("1|0|0|0|0|0|1|0|0|0|0|0|1|0|0|0|0|0|" Matrix "|0|0|0|0|0|1")
Expand Down Expand Up @@ -1277,7 +1277,7 @@ Gdip_DrawImage(pGraphics, pBitmap, dx:="", dy:="", dw:="", dh:="", sx:="", sy:="
{ {
Ptr := A_PtrSize ? "UPtr" : "UInt" Ptr := A_PtrSize ? "UPtr" : "UInt"


if (Matrix&1 = "") if !IsNumber(Matrix)
ImageAttr := Gdip_SetImageAttributesColorMatrix(Matrix) ImageAttr := Gdip_SetImageAttributesColorMatrix(Matrix)
else if (Matrix != 1) else if (Matrix != 1)
ImageAttr := Gdip_SetImageAttributesColorMatrix("1|0|0|0|0|0|1|0|0|0|0|0|1|0|0|0|0|0|" Matrix "|0|0|0|0|0|1") ImageAttr := Gdip_SetImageAttributesColorMatrix("1|0|0|0|0|0|1|0|0|0|0|0|1|0|0|0|0|0|" Matrix "|0|0|0|0|0|1")
Expand Down Expand Up @@ -2781,6 +2781,12 @@ IsInteger(Var) {
Return False Return False
} }


IsNumber(Var) {
Static number := "number"
If Var Is number
Return True
Return False
}






Expand Down
6 changes: 3 additions & 3 deletions README.md
@@ -1,7 +1,7 @@
# AHKv2-Gdip # AHKv2-Gdip
This repository contains the GDI+ library (Gdip_All.ahk) compatible with [AHK v2-a094](https://autohotkey.com/v2/) and also backwards compatible with AHK v1.1.28.02 This repository contains the GDI+ library (Gdip_All.ahk) compatible with [AHK v2-a096](https://autohotkey.com/v2/) and also backwards compatible with AHK v1.1.28.02


AHK v2 made many changes to the syntax, which is why changes were needed. We have attempted to keep it backwards compatible with AHK v1.1. If you find any errors please report them in the Issues. AHK v2 made many changes to the syntax, which is why updates were needed. We have attempted to keep it backwards compatible with AHK v1.1. If you find any errors please report them in the Issues.


Support for AHK v1.0 is dropped (find the original `Gdip_All.ahk` library if you need that). Support for AHK v1.0 is dropped (find the original `Gdip_All.ahk` library if you need that).


Expand All @@ -10,7 +10,7 @@ See the [commit history](https://github.com/mmikeww/AHKv2-Gdip/commits/master) t
# Examples # Examples
All of the tutorial files in the `/Examples/` subfolder work successfully on AHK v2. All of the tutorial files in the `/Examples/` subfolder work successfully on AHK v2.


If you try to run these example files on AHK v1, they will fail. However, the v1 code is still in the files, and simply commented out. Search the example files for "AHK v1" and swap the commented lines to get them working. If you try to run these example files on AHK v1, they will fail. However, the v1 code is still in the files, just simply commented out. Search the example files for "AHK v1" and swap the commented lines to get them working.


# Usage # Usage
All of the Gdip_*() functions use the same syntax as before, so no changes should be required, with one exception: All of the Gdip_*() functions use the same syntax as before, so no changes should be required, with one exception:
Expand Down

0 comments on commit 7575c88

Please sign in to comment.