Jump to content

GDI image save.


Szhlopp
 Share

Recommended Posts

Can't get the image save to work...

I start up all the GDI stuff:

_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¥à¤($)¹Õ¹
Link to comment
Share on other sites

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 by Szhlopp
Link to comment
Share on other sites

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...

#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 by Szhlopp
Link to comment
Share on other sites

  • Moderators

No idea. Although he/she/it probably isn't to happy with me...

ROFL

Actually, 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.

Link to comment
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
 Share

  • Recently Browsing   0 members

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