Jump to content

Processing jpg using GDIPlus


Recommended Posts

Hi guys,

I'm trying to process jpg's using GDIPlus. The code I currently have is: 

#include <MsgBoxConstants.au3>
#include <WinAPI.au3>
#include <GUIConstantsEx.au3>
#include <File.au3>
#include <GDIPlus.au3>

_GDIPlus_Startup()

;There are some jpg screenshots here, ready to be processed
 $LoadedFile = FileFindFirstFile("F:\*.jpg")
 
 ;Tried both of the functions below
 ;$bmap = _GDIPlus_BitmapCreateFromFile($LoadedFile)
 $bmap = _GDIPlus_ImageLoadFromFile($LoadedFile)

; iCol always remains "0", I'm assuming I'm doing something wrong above, and no the resolution isn't an issue
 $iCol = _GDIPlus_BitmapGetPixel($bmap, 500, 550)

 MsgBox($MB_SYSTEMMODAL, "Mouse x, y:","Color: " & $iCol)


_GDIPlus_Shutdown()

Well the comments in the code kinda show what I'm trying to do: Load in jpg's and check certain pixel values.

Owh and I do NOT insist on using the GDIPlus library, it just seemed appropriate.

Edited by iNibble
Link to comment
Share on other sites

Your code works for me

#include <MsgBoxConstants.au3>
#include <GDIPlus.au3>

_GDIPlus_Startup()
 $LoadedFile = StringRegExpReplace(@Autoitexe, '(.+)\\[^\\]+', "$1") & "\Examples\GUI\mslogo.jpg"
 $bmap = _GDIPlus_BitmapCreateFromFile($LoadedFile)
 $iCol = "0x" & Hex(_GDIPlus_BitmapGetPixel($bmap, 250, 20), 6)
 MsgBox($MB_SYSTEMMODAL, "Mouse x, y:","Color: " & $iCol)
_GDIPlus_Shutdown()

 

Link to comment
Share on other sites

Your code works for me

#include <MsgBoxConstants.au3>
#include <GDIPlus.au3>

_GDIPlus_Startup()
 $LoadedFile = StringRegExpReplace(@Autoitexe, '(.+)\\[^\\]+', "$1") & "\Examples\GUI\mslogo.jpg"
 $bmap = _GDIPlus_BitmapCreateFromFile($LoadedFile)
 $iCol = "0x" & Hex(_GDIPlus_BitmapGetPixel($bmap, 250, 20), 6)
 MsgBox($MB_SYSTEMMODAL, "Mouse x, y:","Color: " & $iCol)
_GDIPlus_Shutdown()

​Owh lol. Thanks for verifying that! I was using the file browsing functionality wrong! This is the final code snippet to do it with files from a random directory that worked for me! Thank god this worked.. I alrady started writing my own dll so I could use some jpg processing functions in autoit xD

#include <MsgBoxConstants.au3>
#include <File.au3>
#include <GDIPlus.au3>

_GDIPlus_Startup()

 $SearchDir = "F:\diroffiles\"

 $SearchFile = FileFindFirstFile($SearchDir & "*.jpg")
 $LoadedFile = FileFindNextFile($SearchFile)


 $bmap = _GDIPlus_ImageLoadFromFile($SearchDir & $LoadedFile)
 $iCol = "0x" & Hex(_GDIPlus_BitmapGetPixel($bmap, 600, 100), 6)

 MsgBox($MB_SYSTEMMODAL, "Mouse x, y:","Color: " & $iCol )


_GDIPlus_Shutdown()

 

Edited by iNibble
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...