Sign in to follow this  
Followers 0
jasperhale

Create a white images and mercing another images to it

7 posts in this topic

Sorry about my bad english.

I am trying to create an images with GDI+, called A , the A have white background, after that i mercing another images to A.

Can anyone please teach me how to ???

What i did here :

 

$sIn = @ScriptDir & "\BBBB.jpg"  ; this images have width : 100px and height : 100px

$hBitmap = _ScreenCapture_Capture("", 0, 0, 316, 253)

$hImage = _GDIPlus_BitmapCreateFromHBITMAP($hBitmap)

$aSlice[0] = _GDIPlus_BitmapCloneArea($hImage, 0, 0, 316, 253)

$file3 = @ScriptDir & "\AAAA.jpg"
_GDIPlus_ImageSaveToFile($aSlice[0], $file3)

;;;;; Now the AAAA images with width : 316 and Height 253 have created.

But i cant make it have only white background.

And i dont know how to mercing BBBB.jpg to AAAAA.jpg

Please teach me !!!!

 

Share this post


Link to post
Share on other sites



Does this help you?

#include <Screencapture.au3>

_GDIPlus_Startup()
$hImage_AAAA = _GDIPlus_BitmapCreateFromScan0(316, 253) ;create an empty bitmap
$hCanvas = _GDIPlus_ImageGetGraphicsContext($hImage_AAAA) ;get the graphic context to draw to bitmap
_GDIPlus_GraphicsClear($hCanvas, 0xFFFFFFFF) ;clear the canvas with white color

$hHBitmap = _ScreenCapture_Capture("", 0, 0, 99, 99, False) ;capture the desktop at 0,0 -> 100x100 px
$hImage_BBBB = _GDIPlus_BitmapCreateFromHBITMAP($hHBitmap) ;convert the GDI bitmap to GDI+ format

_GDIPlus_GraphicsDrawImageRect($hCanvas, $hImage_BBBB, 0, 0, 100, 100) ;draw the captured image to our empty bitmap

$file3 = @ScriptDir & "\AAAA.jpg"
_GDIPlus_ImageSaveToFile($hImage_AAAA, $file3) ;save our manual created bitmap

;cleanup resources now
_WinAPI_DeleteObject($hHBitmap)
_GDIPlus_GraphicsDispose($hCanvas)
_GDIPlus_ImageDispose($hImage_AAAA)
_GDIPlus_ImageDispose($hImage_BBBB)
_GDIPlus_Shutdown()

;view now the saved image with default program
ShellExecute($file3)

 


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

#3 ·  Posted (edited)

Hello, when i use this code, i get an error.

C:\Users\Mr.T\Desktop\data\test-watermark10.au3 (4) : ==> Unknown function name.:
$hImage_AAAA = _GDIPlus_BitmapCreateFromScan(316, 253)
$hImage_AAAA = ^ ERROR
>Exit code: 1    Time: 0.

Can you please fix it for me ???

I use SciTE-Lite  Version 2.28

 

Does this help you?

#include <Screencapture.au3>

_GDIPlus_Startup()
$hImage_AAAA = _GDIPlus_BitmapCreateFromScan0(316, 253) ;create an empty bitmap
$hCanvas = _GDIPlus_ImageGetGraphicsContext($hImage_AAAA) ;get the graphic context to draw to bitmap
_GDIPlus_GraphicsClear($hCanvas, 0xFFFFFFFF) ;clear the canvas with white color

$hHBitmap = _ScreenCapture_Capture("", 0, 0, 99, 99, False) ;capture the desktop at 0,0 -> 100x100 px
$hImage_BBBB = _GDIPlus_BitmapCreateFromHBITMAP($hHBitmap) ;convert the GDI bitmap to GDI+ format

_GDIPlus_GraphicsDrawImageRect($hCanvas, $hImage_BBBB, 0, 0, 100, 100) ;draw the captured image to our empty bitmap

$file3 = @ScriptDir & "\AAAA.jpg"
_GDIPlus_ImageSaveToFile($hImage_AAAA, $file3) ;save our manual created bitmap

;cleanup resources now
_WinAPI_DeleteObject($hHBitmap)
_GDIPlus_GraphicsDispose($hCanvas)
_GDIPlus_ImageDispose($hImage_AAAA)
_GDIPlus_ImageDispose($hImage_BBBB)
_GDIPlus_Shutdown()

;view now the saved image with default program
ShellExecute($file3)
Edited by jasperhale

Share this post


Link to post
Share on other sites

Be sure that you use the latest AutoIt version! Older versions might not have a lot of GDI+ functions implemented!


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

Sorry i have update my AUTOIT version and its work now :D.

But you wrong, i am not meaning this problem.

My problem is :

1 / create an empty bitmap with white background.

2/ Open new images AAAA.jpg

3/ draw the image AAAA.JPG to our empty bitmap in step 1

4/ Save the merging images to file.

Can you please help me again ?

Share this post


Link to post
Share on other sites

That's the script I posted exactly doing.

Instead of capturing an area you have to load an image.

 

;remove these two lines
;$hHBitmap = _ScreenCapture_Capture("", 0, 0, 99, 99, False) ;capture the desktop at 0,0 -> 100x100 px
;$hImage_BBBB = _GDIPlus_BitmapCreateFromHBITMAP($hHBitmap) ;convert the GDI bitmap to GDI+ format

;and add this line instead
$hImage_BBBB = _GDIPlus_ImageLoadFromFile("Path to an image")

 


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

Thanks you verry much for your help.

Its work now :D

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  
Followers 0