Jump to content

Recommended Posts

Posted

I want to replace the specified area of picture 1.jpg with picture 2.jpg.

my code is as follow:

#AutoIt3Wrapper_UseX64 = n
#include <GDIPlus.au3>




_GDIPlus_Startup()
Local $hBitmap = _GDIPlus_ImageLoadFromFile(@ScriptDir&'\1.jpg')
Local $hImage_replace = _GDIPlus_ImageLoadFromFile(@ScriptDir&'\2.jpg')

;set the quality 
Local $iJPGQual = 100
Local $sCLSID = _GDIPlus_EncodersGetCLSID("JPG")
Local $tParams = _GDIPlus_ParamInit(10)
Local $tData = DllStructCreate("int Quality")
DllStructSetData($tData, "Quality", $iJPGQual)
Local $pData = DllStructGetPtr($tData)
_GDIPlus_ParamAdd($tParams, $GDIP_EPGQUALITY, 1, $GDIP_EPTLONG, $pData)
Local $pParams = DllStructGetPtr($tParams)  
                    

Local $hGraphic = _GDIPlus_ImageGetGraphicsContext($hBitmap)
_GDIPlus_GraphicsDrawImageRect($hGraphic, $hImage_replace, 98, 98, 60, 60)

_GDIPlus_ImageSaveToFileEx($hBitmap, (@ScriptDir&'\out.jpg'), $sCLSID, $pParams)
                        
;Dispose
_GDIPlus_GraphicsDispose($hGraphic)
_GDIPlus_BitmapDispose($hImage_replace)                         
_GDIPlus_BitmapDispose($hBitmap)
_GDIPlus_Shutdown()

 

 

however, i find the out.jpg  's  quality  is not very good , can anyone help me ?

 

 

question.jpg

 

 

 

 

====================

this is  1.jpg

1.jpg

 

 

 

=======================

this is   2.jpg

2.jpg

Posted (edited)

vectorize the raster. Good luck, as I don't know how.

I did not understand the question at first. The title is misleading.
I guess the amount of pixels to represent 2.jpg gives undesired results.
The only way is to have greater a resolution. More pixels.

Edited by argumentum

Follow the link to my code contribution ( and other things too ).
FAQ - Please Read Before Posting.
autoit_scripter_blue_userbar.png

Posted

I think in the encoding parameters you have to tweak to get your desired result. What happens when you save it to gif, png, tiff, bmp?

check with irfanview your imageproperties if your compression quality is indeed 100 as you are trying or that it has a different quality value

not sure if this can help http://www.mediachance.com/digicam/jpgq.htm it explains a little more

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
  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...