fenhanxue Posted November 25, 2017 Posted November 25, 2017 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 ? ==================== this is 1.jpg ======================= this is 2.jpg
argumentum Posted November 25, 2017 Posted November 25, 2017 (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 November 25, 2017 by argumentum Follow the link to my code contribution ( and other things too ). FAQ - Please Read Before Posting.
junkew Posted November 26, 2017 Posted November 26, 2017 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 FAQ 31 How to click some elements, FAQ 40 Test automation with AutoIt, Multithreading CLR .NET Powershell CMDLets
Recommended Posts
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 accountSign in
Already have an account? Sign in here.
Sign In Now