Absolutely brilliant, ty.
And yes that was the issue all along lol, i needed the Gdip_All.ahk
Thanks again, and sorry i have been a pain.
Regards
Surreall
GDI+ standard library 1.45 by tic
Re: GDI+ standard library 1.45 by tic
Sorry to be a pain, last question i promise.
How do i imagesearch with the pCroppedBitmap?
When i message it, it is a load of numbers. So i presume i need to do a reverse of getbitmap from file. And make file from bitmap?
Regards
Surreall
EDIT: i did read through gdip_all, and didnt see an option for this
How do i imagesearch with the pCroppedBitmap?
When i message it, it is a load of numbers. So i presume i need to do a reverse of getbitmap from file. And make file from bitmap?
Regards
Surreall
EDIT: i did read through gdip_all, and didnt see an option for this
Re: GDI+ standard library 1.45 by tic
You should not use the ahk ImageSearch as this will slow down your script substantially (Especially as you'd have to write to disk which is unnecessary).
Use Masterfocus' Gdip_ImageSearch:
https://github.com/MasterFocus/AutoHotk ... mageSearch
I have not tested it yet however.
If you do want to save a bitmap to disk to use with something else:
Gdip_SaveBitmapToFile
Use Masterfocus' Gdip_ImageSearch:
https://github.com/MasterFocus/AutoHotk ... mageSearch
I have not tested it yet however.
If you do want to save a bitmap to disk to use with something else:
Gdip_SaveBitmapToFile
Re: GDI+ standard library 1.45 by tic
tic you may want to start using the inline code tags instead of the full codeboxes for your one liners
Re: GDI+ standard library 1.45 by tic
Fun with GDIPlus Thread
[AHK] v2.0.5 | [WIN] 11 Pro (Version 22H2) | [GitHub] Profile
Re: GDI+ standard library 1.45 by tic
Any chance of ImageSearch making its way into Gdip2?tic wrote:You should not use the ahk ImageSearch as this will slow down your script substantially (Especially as you'd have to write to disk which is unnecessary).
Use Masterfocus' Gdip_ImageSearch:
https://github.com/MasterFocus/AutoHotk ... mageSearch
I have not tested it yet however.
If you do want to save a bitmap to disk to use with something else:
Gdip_SaveBitmapToFile
Re: GDI+ standard library 1.45 by tic
Definitely. With simple syntax ofGuest wrote:Any chance of ImageSearch making its way into Gdip2?
Code: Select all
gdip := new Gdip()
bitmap1 := gdip.BitmapFromFile("c:\myFile.png")
bitmap2 := gdip.BitmapFromScreen()
isObj := bitmap2.ImageSearch(bitmap1)
Updated above code. GeekDude pointed out an error
Re: GDI+ standard library 1.45 by tic
Code: Select all
gdip := new Gdip()
Re: GDI+ standard library 1.45 by tic
I suppose that means that BitmapFromFile and BitmapFromScreen are subclasses, not methods?tic wrote:Code: Select all
gdip := new Gdip() bitmap1 := new gdip.BitmapFromFile("c:\myFile.png") bitmap2 := new gdip.BitmapFromScreen() isObj := bitmap2.ImageSearch(bitmap1)
Re: GDI+ standard library 1.45 by tic
Thanks for the quick reply, would this be AHK's imagesearch or MasterFocus' faster imagesearch? or are they the same nowadays?tic wrote:Definitely. With simple syntax ofGuest wrote:Any chance of ImageSearch making its way into Gdip2?
Code: Select all
gdip := new Gdip() bitmap1 := gdip.BitmapFromFile("c:\myFile.png") bitmap2 := gdip.BitmapFromScreen() isObj := bitmap2.ImageSearch(bitmap1)
Re: GDI+ standard library 1.45 by tic
I'm not sure it does unless I'm not understanding. Just testing now, if I do:Coco-guest wrote:I'm not sure if intended, but this overrides/changes the object reference(the Class object) stored in the super-global variable Gdip.Code: Select all
gdip := new Gdip()
Code: Select all
gdip := new Gdip()
gdip1 := new Gdip()
Bitmap Is a sub-class and there are a few top-level methods that will return sub-classes. This is to improve readability. Examples areGeekDude wrote:I suppose that means that BitmapFromFile and BitmapFromScreen are subclasses, not methods?
Code: Select all
BitmapFromScreen(params*)
BitmapFromZip(zipObj, file)
BitmapFromFile(file)
As MasterFocus' ImageSearch seems to be used now completely, I would like to take a look at incorporating as-is, or with some modifications after I check the code and with his permission.Guest wrote:Thanks for the quick reply, would this be AHK's imagesearch or MasterFocus' faster imagesearch? or are they the same nowadays?
Edit:
Ah, sorry GeekDude. My bad. Typo. Fixed in my post
Re: GDI+ standard library 1.45 by tic
It'd be similar to doingtic wrote:and use gdip1 from then on, it still works, so new Gdip() wouldn't still work if the class definition had been overriddenCode: Select all
gdip := new Gdip() gdip1 := new Gdip()
Code: Select all
a := new Gdip()
b := new a()
Re: GDI+ standard library 1.45 by tic
Ah, interesting. Technically, 2 objects shouldn't be instantiated of Gdip, but still, it would be bad practice to advise to override the class. Will have to change the variable name in examples. Thanks for the heads up guys.GeekDude wrote: It'll "work", but it's not really the same. Any overrides that a does will be inherited by b. You can thank the wonderful world of prototype OOP for this
Re: GDI+ standard library 1.45 by tic
Code: Select all
gdip := new Gdip() ; gdip.base is Class object
gdip1 := new Gdip() ; gdip1.base is gdip(which is an instance)
By the way, it seems that the purpose for instantiating the Gdip object is to load the library and to free it on __Delete. An issue might be encountered if there are more than one active instance of the class(Gdip) at a time and if any of those instances is released, the __Delete method calls GdiplusShutdown and frees the DLL. The remaining active instance(s) might not be able to use/call the Gdiplus functions since the DLL has already been unloaded. Having said that, IMO, for this specific lib, instances should only be allowed to exist one at a time since only one is really needed at a time. So while an instance is active, __New should be temporarily unavailable. Here's a demo of restricting single instance:
Code: Select all
instance := new SingleInstance()
instance2 := new SingleInstance()
MsgBox % IsObject(instance2) ;false, not an object
instance := "" ; release instance, allow creation of new instance again
new_instance := new SingleInstance()
MsgBox % IsObject(new_instance) ; true
new_instance := ""
class SingleInstance
{
__New()
{
; init code
this._New := SingleInstance.__New ; backup Func reference to __New
SingleInstance.__New := SingleInstance._DummyNew ; temporarily replace the value of '__New' key and have it point to a dummy '__New' method
}
_DummyNew()
{
return false ; disable creation of new instances
}
__Delete()
{
; clean up code
; instance is released, restore original '__New'
SingleInstance.__New := this._New
}
}
Re: GDI+ standard library 1.45 by tic
Very good idea Coco. Thank you. I will implement that now.
Re: GDI+ standard library 1.45 by tic
actually, you can thank AHK syntax choices for confusing you about this. or rather, the choice to cave to the popular request for 'classes'GeekDude wrote:It'll "work", but it's not really the same. Any overrides that a does will be inherited by b. You can thank the wonderful world of prototype OOP for this
in AHK, defining a class Gdip {..} is in reality creating a new object with name "Gdip". you should think of it as essentially doing a Gdip := {k:v, k:v, ..} (but without some of the special class stuff such as __New). in AHK, using the keyword class is in actuality instantianting an object of that name. ie, you can already use the "Gdip" object without calling new
Re: GDI+ standard library 1.45 by tic
Instead of referring to SingleInstance by name inside the class, you should be able to reference it by this.base. I question the usefulness of being able to start/stop gdip manually multiple times. I wonder if it'd be best to just have gdip auto-initiate, and discourage manual creation of new gdip objects.
Code: Select all
class MyClass
{
static _ := MyClass := new MyClass()
__New()
{
MsgBox, Automatically initiated!
}
}
Sure, but that skips the class initiation metafunctions and some other voodoo that goes on when you initialize a class.ie, you can already use the "Gdip" object without calling new
Re: GDI+ standard library 1.45 by tic
but if a user somehow does MyClass := "" will this class be released and no mechanism to start it back up?GeekDude wrote:Instead of referring to SingleInstance by name inside the class, you should be able to reference it by this.base. I question the usefulness of being able to start/stop gdip manually multiple times. I wonder if it'd be best to just have gdip auto-initiate, and discourage manual creation of new gdip objects.
Code: Select all
class MyClass { static _ := MyClass := new MyClass() __New() { MsgBox, Automatically initiated! } }
but i agree its not really useful to start/stop gdip multiple times
right, but thats not the fault of prototype-based OOP when the language is doing some special voodoo in specific instances of object creation and not other instances, merely for convenience and familiarity of using "classes"GeekDude wrote:Sure, but that skips the class initiation metafunctions and some other voodoo that goes on when you initialize a class.ie, you can already use the "Gdip" object without calling new
Re: GDI+ standard library 1.45 by tic
Wouldn't that be an issue with any class? If the user wants to throw away their reference it's on themguest3456 wrote:but if a user somehow does MyClass := "" will this class be released and no mechanism to start it back up?
Do you want me to revise my original post to read something like "guest3456 wrote:right, but thats not the fault of prototype-based OOP when the language is doing some special voodoo in specific instances of object creation and not other instances, merely for convenience and familiarity of using "classes"
Return to “Scripts and Functions (v1)”
Who is online
Users browsing this forum: No registered users and 138 guests