Jump to content
Sign in to follow this  
Makalele

simple & fast graphic filter - plz help

Recommended Posts

Makalele

Hi Everyone!

This is my simple script:

#Include <ScreenCapture.au3>
#Include <GDIPlus.au3>
#include <GUIConstants.au3>

AutoItSetOption("GUICoordMode",0)

Const $clWhite=16777215
Const $clRed=255
Const $clBlack=0

Func Convert($OutputFName,$imgX1,$imgY1,$imgX2,$imgY2)
    Dim $CX=0
    Dim $CY=0
    Dim $IW=$imgX2-$imgX1
    Dim $IH=$imgY2-$imgY1
    Dim $MainBitMap=GUICtrlCreateGraphic(0,0,$IW,$IH)
    Dim $CPIX=0
    
    For $CY=0 To $IH
        
        For $CX=0 to $IW
            
            $CPIX=PixelGetColor($CX+$imgX1,$CY+$imgY1)
            
            IF ($CPIX=$clBlack) OR ($CPIX=$clRed) Then
                GUICtrlSetGraphic($MainBitMap,$GUI_GR_COLOR,$CPIX)   ;pixel ok
            Else
                GUICtrlSetGraphic($MainBitMap,$GUI_GR_COLOR,$clWhite);pixel white
            EndIf
            
            GUICtrlSetGraphic($MainBitMap,$GUI_GR_PIXEL,$CX,$CY)

        Next
        
    Next
    
    
    _GDIPlus_Startup()
    $GraphicBMP = _GDIPlus_BitmapCreateFromGraphics($IW,$IH,$MainBitMap)
    $GraphicHBMP = _GDIPlus_BitmapCreateHBITMAPFromBitmap($GraphicBMP)
    If FileExists($OutputFName) Then FileDelete("tempfile.bmp")
    _ScreenCapture_SaveImage($OutputFName,$GraphicHBMP,False)
    _GDIPlus_Shutdown()
    
EndFunc

An Idea of this script is capture part of screen to GUIGraphic (because i don't know how to copy it to memory and i used GUIGraphic) but with converting all colors to white without black and red. ($cdRed & $cdBlack constans). And in this point is the problem. The script hasn't error, but it isn't make a bmp file.

Of course I'm using this 2 simple commands:

Sleep(5000)
Convert("tempfile.bmp",512,512,600,600)

Where is the problem? Maybe someone has better script? A protity of this script is fast converting.

Please help me :)

Regards,

Makalele


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  

×

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.