Jump to content
Sign in to follow this  
nhockm4v

Add image to image with GDI Plus

Recommended Posts

nhockm4v
Posted (edited)

hello all, this is my code:

#include <GDIPlus.au3>

$image_bg = "bg.png"
$image_logo = "logo.png"
$image_out = "result.png"


 InmageInImage ($image_out, $image_bg, $image_logo, 20)
    
    
Func InmageInImage ($image_out, $image_bg, $image_logo, $Rotate = 0)
    _GDIPlus_Startup ()
    $hBitmap = _GDIPlus_BitmapCreateFromFile ($image_bg)
    $hBitmap1 = _GDIPlus_BitmapCreateFromFile ($image_logo)
    $iW = _GDIPlus_ImageGetWidth ($hBitmap1)
    $iH = _GDIPlus_ImageGetHeight ($hBitmap1)
    $iW2 = $iW / 2
    $iH2 = $iH / 2

    ; rotate
    $hGraphic = _GDIPlus_ImageGetGraphicsContext ($hBitmap)
    $hMatrix = _GDIPlus_Matrixcreate ()
    _GDIPlus_MatrixTranslate ($hMatrix, $iW2, $iW2)
    _GDIPlus_MatrixRotate ($hMatrix, $Rotate) 
    _GDIPlus_GraphicsSetTransform ($hGraphic, $hMatrix)
    _GDIPlus_MatrixTranslate ($hMatrix, -$iW2, -$iW2)
    _GDIPlus_GraphicsDrawImage ($hGraphic, $hBitmap1, -$iW2, -$iH2) 
    _GDIPlus_ImageSaveToFile ($hBitmap, @ScriptDir & "\" & $image_out)
    ShellExecute (@ScriptDir & "\" & $image_out)
    ; dispose
    _GDIPlus_MatrixDispose ($hMatrix)
    _GDIPlus_GraphicsDispose ($hGraphic)
    _GDIPlus_BitmapDispose ($hBitmap)
    _GDIPlus_BitmapDispose ($hBitmap)
    _GDIPlus_Shutdown ()
EndFunc

This code can rotate Add image to image but can not customize image location logo.png in bg.png image, i've tried changing _GDIPlus_GraphicsDrawImage ($hGraphic, $hBitmap1, - $iW2, -$iH2 ) to _GDIPlus_GraphicsDrawImage ( $hGraphic, $hBitmap1, -$iW2 + 20, -$iH2 + 30), but the coordinates are wrong (but if set $ Rotate = 0, it works), any help?

Thank you

code.zip

Edited by nhockm4v

Share this post


Link to post
Share on other sites
nhockm4v

sorry my english not good

Share this post


Link to post
Share on other sites
Andreik
Posted (edited)

Maybe if you upload the images we can help you. And what is _GDIPlus_MatrixTao?

Edited by Andreik
  • Like 1

When the words fail... music speaks

Share this post


Link to post
Share on other sites
nhockm4v
27 minutes ago, Andreik said:

Maybe if you upload the images we can help you. And what is _GDIPlus_MatrixTao?

this is my code and image

code.zip

Share this post


Link to post
Share on other sites
Andreik

Can you edit a photo to see what result do you expect?


When the words fail... music speaks

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  

×