Page 1 of 1

GUI & Image Mapping

Posted: 10 May 2021, 02:46
by Galaxis
Greetings!

I created a montage in Photoshop. This is a single image file that contains 24 different fighting game characters and 5 different button snippets I want to use in my AHK Gui, based on the active tab. Can I specify coordinates and dimesnsions of a button or a fighter within this image to display as my background in the AHK GUI?

Or is AHK only capable of displaying the entire file as background?

I would much rather work with a single image file, instead of keeping track of 20+ seperate image files.

The entire image canvas size is 4000 x 4000 pixels.
Now, say the button snippet is located at x1000 y200, dimensions 90w by 15h.
Can AHK filter just that button for my GUI background?

Thanks.

Re: GUI & Image Mapping

Posted: 10 May 2021, 03:15
by SKAN
You could work around as follows:

Code: Select all

Gui, Add, Text, x1000 y200 w90 h15 BackgroundTrans gButtonSnippet
;...

ButtonSnippet:
;...
Return

Re: GUI & Image Mapping

Posted: 11 May 2021, 13:06
by Galaxis
Thanks, Skan!

But I image with this workaround, the button cannot be moved to the top of the GUI, or elsewhere.

Re: GUI & Image Mapping

Posted: 11 May 2021, 13:48
by SKAN
Ok, I don't want to suggest something silly, again.
You need to clarify.

You have a 4000x4000 image.
You want to crop a piece of it and use it as GUI background?

Re: GUI & Image Mapping

Posted: 11 May 2021, 16:27
by Galaxis
SKAN wrote:
11 May 2021, 13:48
Ok, I don't want to suggest something silly, again.
You need to clarify.

You have a 4000x4000 image.
You want to crop a piece of it and use it as GUI background?
I have multiple buttons in the image file that I want to place at the top of the GUI. One of the buttons I want at coordinates x10 y10 of the GUI. The character button. The 2nd button is called profile, and I want it at x50 y10 of the GUI. Third button is going to be Stats, which I want located x100 y10 of the GUI. And the 4th button is configuration. Of course, the location of these buttons aren't at the coordinates specified, since they are a small part of a single, larger image. I also have comic characters in this image file, that I also want to display in the background depending on which tab is active.
Each button is for a specific tab. The collection of button snippets start at x1000 y200 of the whole image.

Not only do I wish to crop, but to change the XY of the button as well. The button will only be the background of the actual active tab, not the entire GUI.

I want to do this, as opposed to loading all the buttons as it's own separate image. (ie character_button.jpg / profile_button.jpg / configuration_button.jpg)

Re: GUI & Image Mapping  Topic is solved

Posted: 11 May 2021, 16:40
by SKAN
It is not an easy task. You need to use GdiPlus for cropping. Search the forum for GDI+ library.

Re: GUI & Image Mapping

Posted: 12 May 2021, 07:52
by Galaxis
Okidoki. I have the GDIP library already. Just thought it might have been possible with AHK by default. I'll use that then. Thanks!