Jump to content

Black and White screenshot


Goblin
 Share

Recommended Posts

What about "Inverting colors" ?

I used a stupid method... very slow.. but it works.. I just read each pixel and inverted the color values...

the output effect I wantes is actually working :mellow:

Some Projects:[list][*]ZIP UDF using no external files[*]iPod Music Transfer [*]iTunes UDF - fully integrate iTunes with au3[*]iTunes info (taskbar player hover)[*]Instant Run - run scripts without saving them before :)[*]Get Tube - YouTube Downloader[*]Lyric Finder 2 - Find Lyrics to any of your song[*]DeskBox - A Desktop Extension Tool[/list]indifference will ruin the world, but in the end... WHO CARES :P---------------http://torels.altervista.org

Link to comment
Share on other sites

Hey, i want a help in make a small script that takes a screenshot in black and white OR take a normal screenshot and then convert it into Black and white ??

Thanks all !

Goblin

Try this.

#include <GDIPlus.au3>
#include <misc.au3>
#include <ScreenCapture.au3>

$hBitmap1 = _ScreenCapture_Capture("")
_GDIPlus_Startup()

$hImage1 = _GDIPlus_BitmapCreateFromHBITMAP($hBitmap1)
$iImageWidth = _GDIPlus_ImageGetWidth($hImage1)
$iImageHeight = _GDIPlus_ImageGetHeight($hImage1)

$hGraphics = _GDIPlus_ImageGetGraphicsContext($hImage1)
$bitmap = _GDIPlus_BitmapCreateFromGraphics($iImageWidth, $iImageHeight, $hGraphics);  This is actually the buffer
$backbuffer = _GDIPlus_ImageGetGraphicsContext($bitmap); This is to access the buffer

_GDIPlus_GraphicsDrawImageRectRectTrans($backbuffer, $hImage1, 0, 0, $iImageWidth, $iImageHeight)

_GDIPlus_ImageSaveToFile($bitmap, @DesktopDir & "\Test.png")
ShellExecute(@DesktopDir & "\Test.png")

_GDIPlus_GraphicsDispose($hGraphics)
_GDIPlus_GraphicsDispose($backbuffer)
_GDIPlus_ImageDispose ($hImage1)
_GDIPlus_BitmapDispose($bitmap)
_GDIPlus_Shutdown()

Func _GDIPlus_GraphicsDrawImageRectRectTrans($hGraphics, $hImage, $iSrcX, $iSrcY, $iSrcWidth = "", $iSrcHeight = "", _
        $iDstX = "", $iDstY = "", $iDstWidth = "", $iDstHeight = "", $iUnit = 2, $nTrans = 1)
    Local $tColorMatrix, $x, $hImgAttrib, $iW = _GDIPlus_ImageGetWidth($hImage), $iH = _GDIPlus_ImageGetHeight($hImage)
    If $iSrcWidth = 0 Or $iSrcWidth = "" Then $iSrcWidth = $iW
    If $iSrcHeight = 0 Or $iSrcHeight = "" Then $iSrcHeight = $iH
    If $iDstX = "" Then $iDstX = $iSrcX
    If $iDstY = "" Then $iDstY = $iSrcY
    If $iDstWidth = "" Then $iDstWidth = $iSrcWidth
    If $iDstHeight = "" Then $iDstHeight = $iSrcHeight
    If $iUnit = "" Then $iUnit = 2
    ;;create color matrix data
    $tColorMatrix = DllStructCreate("float[5];float[5];float[5];float[5];float[5]")
    ;blending values:
    $x = DllStructSetData($tColorMatrix, 1, 1, 1) * DllStructSetData($tColorMatrix, 1, 1, 2) * DllStructSetData($tColorMatrix, 1, 1, 3) * _
            DllStructSetData($tColorMatrix, 4, $nTrans, 4) * DllStructSetData($tColorMatrix, 5, 1, 5)
    ;;create an image attributes object and update its color matrix
    $hImgAttrib = DllCall($ghGDIPDll, "int", "GdipCreateImageAttributes", "ptr*", 0)
    $hImgAttrib = $hImgAttrib[1]
    DllCall($ghGDIPDll, "int", "GdipSetImageAttributesColorMatrix", "ptr", $hImgAttrib, "int", 1, _
            "int", 1, "ptr", DllStructGetPtr($tColorMatrix), "ptr", 0, "int", 0)
    ;;draw image into graphic object with alpha blend
    DllCall($ghGDIPDll, "int", "GdipDrawImageRectRectI", "hwnd", $hGraphics, "hwnd", $hImage, "int", $iDstX, "int", _
            $iDstY, "int", $iDstWidth, "int", $iDstHeight, "int", $iSrcX, "int", $iSrcY, "int", $iSrcWidth, "int", _
            $iSrcHeight, "int", $iUnit, "ptr", $hImgAttrib, "int", 0, "int", 0)
    ;;clean up
    DllCall($ghGDIPDll, "int", "GdipDisposeImageAttributes", "ptr", $hImgAttrib)
    Return
EndFunc   ;==>_GDIPlus_GraphicsDrawImageRectRectTrans

This line "$x = DllStructSetData($tColorMatrix" makes the first row in the color matrix all ones. this gives the image the B/W effect.

Link to comment
Share on other sites

Another Idea for inverted colors:

$R = 0x00

$G = 0xFF

$B = 0x3D

$R_inverted = $R+(0xFF - $R)

$G_inverted = $G+(0xFF - $G)

$B_inverted = $B+(0xFF - $:mellow:

I'm not sure but it should work fine :(

Some Projects:[list][*]ZIP UDF using no external files[*]iPod Music Transfer [*]iTunes UDF - fully integrate iTunes with au3[*]iTunes info (taskbar player hover)[*]Instant Run - run scripts without saving them before :)[*]Get Tube - YouTube Downloader[*]Lyric Finder 2 - Find Lyrics to any of your song[*]DeskBox - A Desktop Extension Tool[/list]indifference will ruin the world, but in the end... WHO CARES :P---------------http://torels.altervista.org

Link to comment
Share on other sites

Func _InvertedColor($R, $G, $B)
;all of this is Color 0x00FF3D (I haven't got a clue of what the color is) in RGB notation
;now you simply add the difference betewwn max and the hex value for each color the the color itself... so what you get is the "opposite"
$R_inverted = $R+(0xFF - $R)
$G_inverted = $G+(0xFF - $G)
$B_inverted = $B+(0xFF - $B)
;now just put them together
$RGB = $R_inverted & $G_Inverted & $B_inverted
return $RGB
EndFuncoÝ÷ Û­Øb³*.­æy§!¦,^íë­ç§jëh×6For $x = 0 to @DesktopWidth
    For $y = 0 to @DesktopHeight
        PixelGetColor($x, $y)
    Next
    PixelGetColor($x, $y)
Next

just join the three things :mellow:

cheers

Edited by torels

Some Projects:[list][*]ZIP UDF using no external files[*]iPod Music Transfer [*]iTunes UDF - fully integrate iTunes with au3[*]iTunes info (taskbar player hover)[*]Instant Run - run scripts without saving them before :)[*]Get Tube - YouTube Downloader[*]Lyric Finder 2 - Find Lyrics to any of your song[*]DeskBox - A Desktop Extension Tool[/list]indifference will ruin the world, but in the end... WHO CARES :P---------------http://torels.altervista.org

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