Szhlopp Posted September 12, 2008 Posted September 12, 2008 Can't get the image save to work... I start up all the GDI stuff: expandcollapse popup_GDIPlus_Startup() $hGraphics = _GDIPlus_GraphicsCreateFromHWND($hMainGUI) $hImage = _GDIPlus_ImageLoadFromFile(@ScriptDir & '\screenShot0017.jpg') ;$hGraphics = _GDIPlus_ImageGetGraphicsContext($hImage) $iImageWidth = _GDIPlus_ImageGetWidth($hImage) $iImageHeight = _GDIPlus_ImageGetHeight($hImage) _GDIPlus_GraphicsDrawImageRect($hGraphics, $hImage, 0, 0, $iImageWidth, $iImageHeight) $dc = _GDIPlus_GraphicsGetDC($hGraphics) $dll = DllOpen("Gdi32.dll")oÝ÷ Ø[ay'>,^û§rب«¢µæ{bë¶Þ¶Ü¦¹È^«²Ø^m§$º.×(ÚºÚ"µÍÜ ÌÍÖHHHÈ ÌÍÚR[XYÙRZYÚQÜ ÌÍÖHHÈ ÌÍÚR[XYÙUÚYBNÉÌÍÖHHÈLÌL ÌBNÉÌÍÖHHBBIÌÍÝ[HØ[ ÌÍÙ ][ÝÚ[ ][ÝË ][ÝÑÙ]^[ ][ÝË ][ÝÜ][ÝË ÌÍÙË ][ÝÚ[ ][ÝË ÌÍÖ ][ÝÚ[ ][ÝË ÌÍÖJBBIÌÍÑY[ÙHHXÊ[ XÊ ÌÍÐÒVÛÛÜJHH ÌÍÝ[ÌJBBRY ÌÍÑY[ÙH ÏH ÌÍÕX[ÙH[BBQØ[ ÌÍÙ ][ÝÚ[ ][ÝË ][ÝÔÙ]^[ ][ÝË ][ÝÜ][ÝË ÌÍÙË ][ÝÚ[ ][ÝË ÌÍÖ ][ÝÚ[ ][ÝË ÌÍÖK ][ÝÙÛÜ ][ÝË BBBNÓÙÐÞ ][ÝÉ][ÝË ÌÍÑY[ÙJBBQ[YS^B^oÝ÷ Ù8b±©eÂä² ÞjÒ'£ '(Z½ì!jÒ0j{eyûl"§!#§v £hÁÚ±«Þ¶¬f ybØ^nVçhºÚbÅélN§È§iÛÚǺY@ºÚµ«¢+Ø¥¹±Õ±ÐíU% ½¹ÍѹÑ̹ÔÌÐì(¥¹±Õ±Ðí%A±Õ̹ÔÌÐì(¥¹±Õ±Ðí]¥¹A$¹ÔÌÐì(ì)!½Ñ-åMÐ ÅÕ½ÐííÅôÅÕ½Ðì°ÅÕ½ÐíÑ ½±½ÈÅÕ½Ðì¤(ÀÌØí¡5¥¹U$ôU% ÉÑ ÅÕ½Ðí½É´ÄÅÕ½Ðì°ØÄÀ°ØÀÀ°ÌÔÈ°ÄàȤ)U%MÑMÑÑ¡M]}M!=¤()}%A±ÕÍ}MÑÉÑÕÀ ¤(ÀÌØí¡ÉÁ¡¥Ìô}%A±ÕÍ}ÉÁ¡¥Í ÉÑɽµ!]9 ÀÌØí¡5¥¹U$¤(ÀÌØí¡%µô}%A±ÕÍ}%µ1½É½µ¥±¡MÉ¥ÁѥȵÀìÌäìÀäÈíÍɹM¡½ÐÀÀÄܹ©ÁÌäì¤(ìÀÌØí¡ÉÁ¡¥Ìô}%A±ÕÍ}%µÑÉÁ¡¥Í ½¹ÑáÐ ÀÌØí¡%µ¤(ÀÌØí¥%µ]¥Ñ ô}%A±ÕÍ}%µÑ]¥Ñ ÀÌØí¡%µ¤(ÀÌØí¥%µ!¥¡Ðô}%A±ÕÍ}%µÑ!¥¡Ð ÀÌØí¡%µ¤)}%A±ÕÍ}ÉÁ¡¥ÍÉÝ%µIÐ ÀÌØí¡ÉÁ¡¥Ì°ÀÌØí¡%µ°À°À°ÀÌØí¥%µ]¥Ñ °ÀÌØí¥%µ!¥¡Ð¤(ÀÌØíô}%A±ÕÍ}ÉÁ¡¥ÍÑ ÀÌØí¡ÉÁ¡¥Ì¤(ÀÌØí±°ô±±=Á¸ ÅÕ½Ðí¤Ìȹ±°ÅÕ½Ðì¤((í ±=ÕÑ ¬ ÀÌØí°ØÔÔäÈä°ÔäÀÀÀÀ¤) ±½ÕÑQáÐ ÀÌØí°!à ÅÕ½ÐìÄÈäÄÀÔààÅÕ½Ð줤((ÀÌØí]@ô]¥¹ÑA½Ì ÀÌØí¡5¥¹U$¤(ÀÌØíMÉ ôA¥á±MÉ ÀÌØí]AlÁt°ÀÌØí]AlÁt°ÀÌØí]AlÁt¬ÀÌØí]AlÉt°ÀÌØí]AlÁt¬ÀÌØí]AlÍt°ÄÈäÄÀÔàà¤)%ÉɽȱÐìÐìÄQ¡¸($($($ÀÌØí½±½ÈôA¥á±Ñ ½±½È ÀÌØíMÉ¡lÁt°ÀÌØíMÉ¡lÅt¤($($(%5½ÕÍ5½Ù ÀÌØíMÉ¡lÁt°ÀÌØíMÉ¡lÅt¤)¹%(((()]¡¥±Ä($ÀÌØí¹5ÍôU%Ñ5Í ¤(%MÝ¥Ñ ÀÌØí¹5Í($% ÍÀÌØíU%}Y9Q} 1=M($$%}%A±ÕÍ}ÉÁ¡¥ÍI±Í ÀÌØí¡ÉÁ¡¥Ì°ÀÌØí¤($$%á¥Ð((%¹MÝ¥Ñ )]¹(()Õ¹ ±=ÕÑ ¬ ÀÌØí°ÀÌØí !a ½±½È°ÀÌØíYÉ¥¹ôÔÀÀÀÀÀ¤(()½ÈÀÌØídôÄQ¼ÀÌØí¥%µ!¥¡Ð((%½ÈÀÌØí`ôÄQ¼ÀÌØí¥%µ]¥Ñ ($$ìÀÌØí`ôÄìÄÌÄÀÜÈ($$ìÀÌØídôÄ($$ÀÌØíѵÀô±± ±° ÀÌØí±°°ÅÕ½Ðí¥¹ÐÅÕ½Ðì°ÅÕ½ÐíÑA¥á°ÅÕ½Ðì°ÅÕ½ÐíÁÑÈÅÕ½Ðì°ÀÌØí°ÅÕ½Ðí¥¹ÐÅÕ½Ðì°ÀÌØí`°ÅÕ½Ðí¥¹ÐÅÕ½Ðì°ÀÌØíd¤($$ÀÌØí¥É¹ôÌ¡%¹Ð¡ ÀÌØí !a ½±½È¤¤´ÀÌØíѵÁlÁt¤($%%ÀÌØí¥É¹±ÐìôÀÌØíYÉ¥¹Q¡¸($$%±± ±° ÀÌØí±°°ÅÕ½Ðí¥¹ÐÅÕ½Ðì°ÅÕ½ÐíMÑA¥á°ÅÕ½Ðì°ÅÕ½ÐíÁÑÈÅÕ½Ðì°ÀÌØí°ÅÕ½Ðí¥¹ÐÅÕ½Ðì°ÀÌØí`°ÅÕ½Ðí¥¹ÐÅÕ½Ðì°ÀÌØíd°ÅÕ½ÐíݽÉÅÕ½Ðì°ÁàÀÀÀÀÀÀ¤($$$í5Í ½à À°ÅÕ½ÐìÅÕ½Ðì°ÀÌØí¥É¹¤($%¹%((%9áÐ($)9áÐ()¹Õ¹()Õ¹ ±½ÕÑQáÐ ÀÌØí°ÀÌØíQáÑ ½±½È°ÀÌØíYÉ¥¹ôÐÈÀÀÀÀÀ¤(()½ÈÀÌØídôÄQ¼ÀÌØí¥%µ!¥¡Ð´Ä((%½ÈÀÌØí`ôÄQ¼ÀÌØí¥%µ]¥Ñ ´Ä($$ìÀÌØí`ôÄìÄÌÄÀÜÈ($$ìÀÌØídôÄ($$ÀÌØíѵÀô±± ±° ÀÌØí±°°ÅÕ½Ðí¥¹ÐÅÕ½Ðì°ÅÕ½ÐíÑA¥á°ÅÕ½Ðì°ÅÕ½ÐíÁÑÈÅÕ½Ðì°ÀÌØí°ÅÕ½Ðí¥¹ÐÅÕ½Ðì°ÀÌØí`°ÅÕ½Ðí¥¹ÐÅÕ½Ðì°ÀÌØíd¤($$ÀÌØí¥É¹ôÌ¡%¹Ð¡ ÀÌØíQáÑ ½±½È¤¤´ÀÌØíѵÁlÁt¤($%%ÀÌØí¥É¹ÐìôÀÌØíYÉ¥¹Q¡¸($$%±± ±° ÀÌØí±°°ÅÕ½Ðí¥¹ÐÅÕ½Ðì°ÅÕ½ÐíMÑA¥á°ÅÕ½Ðì°ÅÕ½ÐíÁÑÈÅÕ½Ðì°ÀÌØí°ÅÕ½Ðí¥¹ÐÅÕ½Ðì°ÀÌØí`°ÅÕ½Ðí¥¹ÐÅÕ½Ðì°ÀÌØíd°ÅÕ½ÐíݽÉÅÕ½Ðì°ÁàÀÀÀÀÀÀ¤($$$í5Í ½à À°ÅÕ½ÐìÅÕ½Ðì°ÀÌØí¥É¹¤($%¹%((%9áÐ($)9áÐ()¹Õ¹((ìÄÈäÄÀÔàà()Õ¹Ñ ½±½È ¤($($ÀÌØí5@ô5½ÕÍÑA½Ì ¤($ÀÌØíA¥àôA¥á±Ñ ½±½È ÀÌØí5AlÁt°ÀÌØí5AlÅt¤(%QÉåQ¥À ÅÕ½Ðí ½±½ÈÅÕ½Ðì°ÀÌØíA¥à°Ä¤(% ±¥ÁAÕÐ ÀÌØíA¥à¤($)¹Õ¹ RegEx/RegExRep Tester!Nerd Olympics - Community App!Login UDFMemory UDF - "Game.exe+753EC" - CE pointer to AU3Password Manager W/ SourceDataFiler - Include files in your au3!--- Was I helpful? Click the little green '+'
Andreik Posted September 12, 2008 Posted September 12, 2008 GDIPlus_BitmapCreateFromGraphics() and then _GDIPlus_ImageSaveToFile.
Szhlopp Posted September 12, 2008 Author Posted September 12, 2008 (edited) GDIPlus_BitmapCreateFromGraphics() and then _GDIPlus_ImageSaveToFile.I tried this. I'll try it again and post the code here. As well as the photo I was using.Brb Also. Could I PLEASE get a dev to remove this "Community" guys dumb post? I'm to stinking tired of seeing that same thing over and over... Edited September 12, 2008 by Szhlopp RegEx/RegExRep Tester!Nerd Olympics - Community App!Login UDFMemory UDF - "Game.exe+753EC" - CE pointer to AU3Password Manager W/ SourceDataFiler - Include files in your au3!--- Was I helpful? Click the little green '+'
monoceres Posted September 12, 2008 Posted September 12, 2008 You really shouldn't draw important things directly to the GUI. Instead draw them in memory somewhere. Second time in the last 30 minutes I refer to my backbuffer example #577036 Broken link? PM me and I'll send you the file!
Andreik Posted September 12, 2008 Posted September 12, 2008 What is with Community On Patrol? I hope that is not a bot, he knows a say one thing: "Welcome to the AutoIt Forums!" >_
Szhlopp Posted September 12, 2008 Author Posted September 12, 2008 (edited) What is with Community On Patrol? I hope that is not a bot, he knows a say one thing: "Welcome to the AutoIt Forums!" >_< No idea. Although he/she/it probably isn't to happy with me... ROFL I just tried the bitmap create again on the $hGraphics Item. The file never even wrote. I tried it with a jpg/bmp. Also here is the sample image I'm working with (Good for almost solid Background) @Mono I'll look at that and see if this can fix my problem=) Edit: Code for saving it... expandcollapse popup#include <GUIConstants.au3> #include <GDIPlus.au3> #include <WinAPI.au3> ; HotKeySet("{F1}", "GetColor") $hMainGUI = GUICreate("Form1", 610, 600, 352, 182) GUISetState(@SW_SHOW) _GDIPlus_Startup() $hGraphics = _GDIPlus_GraphicsCreateFromHWND($hMainGUI) $hImage = _GDIPlus_ImageLoadFromFile(@ScriptDir & '\screenShot0017.jpg') ;$hGraphics = _GDIPlus_ImageGetGraphicsContext($hImage) $iImageWidth = _GDIPlus_ImageGetWidth($hImage) $iImageHeight = _GDIPlus_ImageGetHeight($hImage) _GDIPlus_GraphicsDrawImageRect($hGraphics, $hImage, 0, 0, $iImageWidth, $iImageHeight) $dc = _GDIPlus_GraphicsGetDC($hGraphics) $dll = DllOpen("Gdi32.dll") ;BlackOutBack($dc, 655929, 590000) BlackoutText($dc, Hex("12910588")) $hImageSave = _GDIPlus_BitmapCreateFromGraphics($iImageWidth, $iImageHeight, $hGraphics) _GDIPlus_ImageSaveToFile($hImageSave, @ScriptDir & '\Saveimg.jpg') Exit $aWP = WinGetPos($hMainGUI) $Search = PixelSearch($aWP[0], $aWP[0], $aWP[0] + $aWP[2], $aWP[0] + $aWP[3], 12910588) If @error <> 1 Then $color = PixelGetColor($Search[0], $Search[1]) MouseMove($Search[0], $Search[1]) EndIf While 1 $nMsg = GUIGetMsg() Switch $nMsg Case $GUI_EVENT_CLOSE _GDIPlus_GraphicsReleaseDC($hGraphics, $dc) Exit EndSwitch WEnd Func BlackOutBack($dc, $BkHEXColor, $Variance = 500000) For $Y = 1 To $iImageHeight For $X = 1 To $iImageWidth ;$X = 1 ; 131072 ;$Y = 1 $temp = DllCall($dll, "int", "GetPixel", "ptr", $dc, "int", $X, "int", $Y) $Difference = Abs(Int(Dec($BkHEXColor)) - $temp[0]) If $Difference <= $Variance Then DllCall($dll, "int", "SetPixel", "ptr", $dc, "int", $X, "int", $Y, "dword", 0x000000) ;MsgBox(0, "", $Difference) EndIf Next Next EndFunc Func BlackoutText($dc, $TextColor, $Variance = 4200000) For $Y = 1 To $iImageHeight - 1 For $X = 1 To $iImageWidth - 1 ;$X = 1 ; 131072 ;$Y = 1 $temp = DllCall($dll, "int", "GetPixel", "ptr", $dc, "int", $X, "int", $Y) $Difference = Abs(Int(Dec($TextColor)) - $temp[0]) If $Difference >= $Variance Then DllCall($dll, "int", "SetPixel", "ptr", $dc, "int", $X, "int", $Y, "dword", 0x000000) ;MsgBox(0, "", $Difference) EndIf Next Next EndFunc ; 12910588 Func GetColor() $aMP = MouseGetPos() $Pix = PixelGetColor($aMP[0], $aMP[1]) TrayTip("Color", $Pix,1) ClipPut($Pix) EndFunc Edited September 12, 2008 by Szhlopp RegEx/RegExRep Tester!Nerd Olympics - Community App!Login UDFMemory UDF - "Game.exe+753EC" - CE pointer to AU3Password Manager W/ SourceDataFiler - Include files in your au3!--- Was I helpful? Click the little green '+'
Moderators SmOke_N Posted September 12, 2008 Moderators Posted September 12, 2008 No idea. Although he/she/it probably isn't to happy with me...ROFLActually, they're probably laughing at you . Common sense plays a role in the basics of understanding AutoIt... If you're lacking in that, do us all a favor, and step away from the computer.
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