Jump to content
Sign in to follow this  

GDI, Png, Transparency and Loops

Recommended Posts


This is my first post. I've spent a lot of time testing different approaches and of course searching the forums before posting this. It's been 3 days already, so I think it's about time I ask the experts.

I'm trying to merge several images into one big file. Images should be aligned one next to the other. So far I've got almost everything. I'm creating an empty image (like a canvas to paint on) with transparency. I can save it to a PNG format. It works, but I don't want to save it just yet. I want to read a couple of images (all same predefined size) and draw them on the canvas. This is what doesn't work. The funny thing is, that when I use _ScreenCapture_Capture instead of reading the file it works, but I can't make it work with a file. There are so many ways to load a file and I'm getting lost. 

Right now I'm trying to read a JPG file (so no transparency). I can't make it work, however it does work if I use screen capture (as explained above) and the canvas gets filled with multiple copies of my screen capture area as expected. In the end I'll be loading PNG files which also include transparency - I don't know if it makes any difference, but I thought to point that out.

I'm using _GDIPlus_GraphicsDrawImage to paint on the "canvas".

Any ideas?

Share this post

Link to post
Share on other sites

Thanks UEZ. I see you'r "the man" around here :) I've seen that example, and I'm constantly trying out ideas based on that, but I can't get rid of the feeling that I'm so close and I should't have to go through all that code and trying out different bits without really knowing why one way works, and the other doesn't.

On top of that everything works. It just doesn't work when the file is being loaded. So my guess is the ScreenCapture returns a different type than loading images using which ever method, but the Documentation doesn't specify it.

Also here's the small part of the code:

For $j = 1 to $currentFileList[0]
        $x = mod($j-1, $stripeSize[0][0]) * $stripeSize[1][0]
        $y = floor(($j-1) / $stripeSize[0][1]) * $stripeSize[1][1]
        $hBitmap = _ScreenCapture_Capture("", 0, 0, 286, 288)
        $hImage = _GDIPlus_BitmapCreateFromHBITMAP($hBitmap)
        _GDIPlus_GraphicsDrawImage($hGraphic, $hImage, $x, $y)

after that I'm saving the $canvas and clearing the resources.

the $canvas is created using _WinAPI_CreateBitmap, _GDIPlus_BitmapLockBits, and so on.

this is working as expected, but when I try to substitute the _ScreenCapture with loading an image all I get is a blank file.

Edited by explorerpl

Share this post

Link to post
Share on other sites

_ScreenCapture_Capture() creates a GDI bitmap. To use it in GDI+ you have to convert the image by using _GDIPlus_BitmapCreateFromHBITMAP() function. Afterwards you can use it e.g. to copy to the canvas.

_GDIPlus_BitmapCreateFromScan0() comes from GDIP.au3 which can be found here: '?do=embed' frameborder='0' data-embedContent>>

It creates an empty GDI+ bitmap.



Please don't send me any personal message and ask for support! I will not reply!

Selection of finest graphical examples at Codepen.io

The own fart smells best!
Her 'sikim hıyar' diyene bir avuç tuz alıp koşma!
¯\_(ツ)_/¯  ٩(●̮̮̃•̃)۶ ٩(-̮̮̃-̃)۶ૐ

Share this post

Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
Sign in to follow this  

  • Recently Browsing   0 members

    No registered users viewing this page.

  • Create New...