Jump to content

Recommended Posts

Posted

Nice one i will try it now..

AIT stands for AutoIt Image Texture :D

[edit]

#include <GUIConstants.au3>
#include <BMP.au3>

GUICreate("Woot", 400,400)
GUICtrlCreateGraphic(0,0)

    $bmp = _OpenBMP("206px-Angelina_Jolie_Tomb_Raider.bmp",0)
    If IsArray($bmp) Then
        For $x = 0 to UBound($bmp,1)-1
            For $y = 0 to UBound($bmp,2)-1
                GUICtrlSetGraphic(-1, $GUI_GR_COLOR,Dec(_PixelRead($bmp,$x,$y)));Dec($bmp[$x][$y]) gives the same..
                GUICtrlSetGraphic(-1, $GUI_GR_PIXEL,$x,$y)
            Next
        Next
    EndIf

GUISetState()

While 1
    If GUIGetMsg() = -3 Then
        Exit
    EndIf
WEnd

Gives this:

Tha code runs fine on my PC...i get a normal image... can you maybe attach the image file you are using?
Posted

Yes you can use my code and example for the official release.

Thanks RazerM :D I kinda assumed you wouldn't mind and put your example in yesterday, plz don't hurt me :D

Much appreciated!

Posted (edited)

When i opened a bmp and displayed it with graphic controls it was blue instead of yellow

This is the bmp:

Edited by RazerM
My Programs:AInstall - Create a standalone installer for your programUnit Converter - Converts Length, Area, Volume, Weight, Temperature and Pressure to different unitsBinary Clock - Hours, minutes and seconds have 10 columns each to display timeAutoIt Editor - Code Editor with Syntax Highlighting.Laserix Editor & Player - Create, Edit and Play Laserix LevelsLyric Syncer - Create and use Synchronised Lyrics.Connect 4 - 2 Player Connect 4 Game (Local or Online!, Formatted Chat!!)MD5, SHA-1, SHA-256, Tiger and Whirlpool Hash Finder - Dictionary and Brute Force FindCool Text Client - Create Rendered ImageMy UDF's:GUI Enhance - Enhance your GUIs visually.IDEA File Encryption - Encrypt and decrypt files easily! File Rename - Rename files easilyRC4 Text Encryption - Encrypt text using the RC4 AlgorithmPrime Number - Check if a number is primeString Remove - remove lots of strings at onceProgress Bar - made easySound UDF - Play, Pause, Resume, Seek and Stop.
Posted (edited)

Yes, looks like some problem with the GUISetGraphic function... the BMP shows up fine when i write it to a file... try this-

GUICreate("Woot", 400,400)
GUICtrlCreateGraphic(0,0)

$bmp = _OpenBMP("signature.bmp",1)
   
If IsArray($bmp) Then
    For $y = UBound($bmp,2)-1 to 0 step -1
        For $x = 0 to UBound($bmp,1)-1 step 1
            $temp=_PixelRead($bmp,$x,$y)
            GUICtrlSetGraphic(-1, $GUI_GR_COLOR,"0x"&StringMid($temp,5,2)&StringMid($temp,3,2)&StringMid($temp,1,2))
            GUICtrlSetGraphic(-1, $GUI_GR_PIXEL,$x,$y)
        Next
    Next
EndIf
GUISetState()

While 1
    If GUIGetMsg() = -3 Then
        Exit
    EndIf
WEnd

Looks like its BBRRGG instead of RRGGBB

Edited by evilertoaster
Posted (edited)

Yes i noticed the bmp was written using BGR when writing the example. At least that workaround works.

Created a Function To help

#include <GUIConstants.au3>
#include <BMP.au3>
GUICreate("BGR to RGB", 400,400)
GUICtrlCreateGraphic(0,0)

$bmp = _OpenBMP("signature.bmp",1)
$bmp_rgb = _BMPToRGB($bmp)
If IsArray($bmp) Then
    For $x = 0 to UBound($bmp_rgb,1)-1
        For $y = 0 to UBound($bmp_rgb,2)-1
            GUICtrlSetGraphic(-1, $GUI_GR_COLOR,Dec(_PixelRead($bmp_rgb,$x,$y)))
            GUICtrlSetGraphic(-1, $GUI_GR_PIXEL,$x,$y)
        Next
    Next
EndIf

GUISetState()

Do
Until GUIGetMsg() = -3

Func _BMPToRGB($BMP)
    Local $BMP2 = $BMP
    For $x = 0 to UBound($bmp,1)-1
        For $y = 0 to UBound($bmp,2)-1
            $temp = $BMP[$x][$y]
            If $temp <> "" Then $BMP2[$x][$y] = StringMid($temp, 5, 2) & StringMid($temp, 3, 2) & StringMid($temp, 1, 2)
        Next
    Next
    Return $BMP2
EndFuncoÝ÷ Ù.r¥u©l¡§]jz-êéj¶¦j׫¶âÅéQy§eG­+ºÚ"µÍ[ÈÔ^[XY
TY  ÌÍÐT[K   ÌÍÞ  ÌÍÞK ÌÍØÛÛÜHH  ][ÝÐÔ][ÝÊBSØØ[   ÌÍÕÚYUPÝ[
    ÌÍÐT[KJBSØØ[   ÌÍÒZYÚUPÝ[
    ÌÍÐT[KBRY    ÌÍÞ  ÝÉÌÍÕÚYLHÜ   ÌÍÞ  ÌÜ    ÌÍÞIÝÉÌÍÒZYÚLHÜ   ÌÍÞIÌ[]
LJBRY   ÌÍØÛÛÜH   ÉÝÈ  ][ÝÔÐ][ÝÈÜ    ÌÍØÛÛÜH   ÉÝÈ  ][ÝÔÐ][ÝÈ[]IÌÍØÛÛÜIÌÍÐT[VÉÌÍÞVÉÌÍÞWBRY    ÌÍØÛÛÜI][ÝÉ][ÝÈ[  ÌÍÐÛÛÜI][ÝÑ][ÝÂRY ÌÍØÛÛÜHH  ][ÝÐÔ][ÝÈ[]    ÌÍÐÛÛÜRY  ÌÍØÛÛÜHH  ][ÝÔÐ][ÝÈ[]Ý[ÓZY
    ÌÍÐÛÛÜ
KH  [ÈÝ[ÓZY
    ÌÍÐÛÛÜËH [ÈÝ[ÓZY
    ÌÍÐÛÛÜKB[[Â

It uses BGR as default so all current scripts will work fine

If the user wants it to return the colour in RGB they use "RGB" as the last parameter

Edited by RazerM
My Programs:AInstall - Create a standalone installer for your programUnit Converter - Converts Length, Area, Volume, Weight, Temperature and Pressure to different unitsBinary Clock - Hours, minutes and seconds have 10 columns each to display timeAutoIt Editor - Code Editor with Syntax Highlighting.Laserix Editor & Player - Create, Edit and Play Laserix LevelsLyric Syncer - Create and use Synchronised Lyrics.Connect 4 - 2 Player Connect 4 Game (Local or Online!, Formatted Chat!!)MD5, SHA-1, SHA-256, Tiger and Whirlpool Hash Finder - Dictionary and Brute Force FindCool Text Client - Create Rendered ImageMy UDF's:GUI Enhance - Enhance your GUIs visually.IDEA File Encryption - Encrypt and decrypt files easily! File Rename - Rename files easilyRC4 Text Encryption - Encrypt text using the RC4 AlgorithmPrime Number - Check if a number is primeString Remove - remove lots of strings at onceProgress Bar - made easySound UDF - Play, Pause, Resume, Seek and Stop.
Posted

OK cool. Will add the pixel read function but on thing first about the BMP converter...I work's from what I see but I'm thinking it will need to be converted back before BMPwrite works correctly... ill be working on it.

And also it says the defualt color is autoit should be in BGR? Is this an actual bug with the setgraphic function?

Posted (edited)

The default colour in AutoIt is RGB, use

Opt("ColorMode", 1)oÝ÷ ÚÚ.±àFE.r¥v·§jg0ôèD`m 
h¬Êy,¥«­¢+ÙÕ¹} 5A
½±½É5½MÝÀ ÀÌØí   5(1½°ÀÌØí  5@ÈôÀÌØí  5@(½ÈÀÌØíàôÀѼU  ½Õ¹ ÀÌØíµÀ°Ä¤´Ä(½ÈÀÌØíäôÀѼU   ½Õ¹ ÀÌØíµÀ°È¤´Ä(ÀÌØíѵÀôÀÌØí  5AlÀÌØíáulÀÌØíåt(%ÀÌØíѵÀ±ÐìÐìÅÕ½ÐìÅÕ½ÐìQ¡¸ÀÌØí   5@ÉlÀÌØíáulÀÌØíåtôMÑÉ¥¹5¥ ÀÌØíѵÀ°Ô°È¤µÀìMÑÉ¥¹5¥ ÀÌØíѵÀ°Ì°È¤µÀìMÑÉ¥¹5¥ ÀÌØíѵÀ°Ä°È¤(9áÐ(9áÐ(IÑÕɸÀÌØí 5)¹Õ¹

because it changes the order both ways. On the other hand it does'nt edit the original array, a copy is made. In the post i made earlier i use $bmp_rgb as the new array, $bmp is untouched.

Edited by RazerM
My Programs:AInstall - Create a standalone installer for your programUnit Converter - Converts Length, Area, Volume, Weight, Temperature and Pressure to different unitsBinary Clock - Hours, minutes and seconds have 10 columns each to display timeAutoIt Editor - Code Editor with Syntax Highlighting.Laserix Editor & Player - Create, Edit and Play Laserix LevelsLyric Syncer - Create and use Synchronised Lyrics.Connect 4 - 2 Player Connect 4 Game (Local or Online!, Formatted Chat!!)MD5, SHA-1, SHA-256, Tiger and Whirlpool Hash Finder - Dictionary and Brute Force FindCool Text Client - Create Rendered ImageMy UDF's:GUI Enhance - Enhance your GUIs visually.IDEA File Encryption - Encrypt and decrypt files easily! File Rename - Rename files easilyRC4 Text Encryption - Encrypt text using the RC4 AlgorithmPrime Number - Check if a number is primeString Remove - remove lots of strings at onceProgress Bar - made easySound UDF - Play, Pause, Resume, Seek and Stop.
Posted

Thanks for the ideas RazerM, I went about it a differnt way in the end (I think it's simpler this way).

The color will simply be whichever is defined by the AutoIt option "ColorMode". See the updated version.

Posted

Looks really good, I'm not on a computer with AutoIt at the moment. I'll try it later.

My Programs:AInstall - Create a standalone installer for your programUnit Converter - Converts Length, Area, Volume, Weight, Temperature and Pressure to different unitsBinary Clock - Hours, minutes and seconds have 10 columns each to display timeAutoIt Editor - Code Editor with Syntax Highlighting.Laserix Editor & Player - Create, Edit and Play Laserix LevelsLyric Syncer - Create and use Synchronised Lyrics.Connect 4 - 2 Player Connect 4 Game (Local or Online!, Formatted Chat!!)MD5, SHA-1, SHA-256, Tiger and Whirlpool Hash Finder - Dictionary and Brute Force FindCool Text Client - Create Rendered ImageMy UDF's:GUI Enhance - Enhance your GUIs visually.IDEA File Encryption - Encrypt and decrypt files easily! File Rename - Rename files easilyRC4 Text Encryption - Encrypt text using the RC4 AlgorithmPrime Number - Check if a number is primeString Remove - remove lots of strings at onceProgress Bar - made easySound UDF - Play, Pause, Resume, Seek and Stop.
Posted (edited)

hm..i tested it but it somehow destroys the wholepicture :D

Edit:

Okay the Problem is only if i save the picture without renaming it...

Example:

$bmphandle = _BMPOpen($bmppath)
;stuff like...
_PixelWrite($bmphandle,0,0,$color)
;
_BMPWrite($BMPHandle,$bmppath)

Just change the _BMPWrite path to something like @Scriptdir &"\edited.bmp"

Edited by XxXFaNtA
Posted

hm..i tested it but it somehow destroys the wholepicture :D

Edit:

Okay the Problem is only if i save the picture without renaming it...

Example:

$bmphandle = _BMPOpen($bmppath)
;stuff like...
_PixelWrite($bmphandle,0,0,$color)
;
_BMPWrite($BMPHandle,$bmppath)

Just change the _BMPWrite path to something like @Scriptdir &"\edited.bmp"

Hey, yes that would do it....the writing for the BMPWrite is done in 'add to end of file' write mode. For this reason it wouldn't really work to write to an already existing file. I've added a check for this which I'll put in the new version.

@Manadar- Humm, this looks like a problem that was occuring before...I will be looking at it agian. For now if you open it in mspaint and change the size to somthing like 200x160 it seems to work fine....Don't knw why yet...

Posted

i really like the program..i'm already making something with it...is there also a way to get the image dimensions (width and height?).

Ah...and as i tested the Script with a bigger Image i had a nice bug that the progress bar change from 1 to 0 xD...and it loaded the bitmap veeeery slowly

But still great job on this!

Posted (edited)

Yes, BMPs are stored in a pretty simple array. So width should be Ubound($BMPHandle,1), and height should be Ubound($BMPHandle,2).

Progress bar glictch may be resolved now, but don't worry to much about it, I have to offset the actual progress at the begining and end becuase the formula to get the %done requires a division by 0...and yes like mentioned on first post it is still pretty slow (is faster now than in 1.5 but still)...not to much i can do really (I'm open to any speed enhancement sugestions trust me^^)

Manadar- The problem should be fixed now... please let me know if it's not (bmp's seem to have alot of different format options :D ) and can send some example bmp's

Edit: It's updated to 1.7 BTW

Edited by evilertoaster
  • 1 month later...
  • 2 weeks later...
Posted

I've been trying to use this and I'm getting this error message now that I'm using AutIT 3.2.0.1

C:\AutoIt3\Projects\BMP.au3(304,29) : ERROR: Opt() [built-in] called with wrong number of args.

Local $type=Opt("ColorMode")

~~~~~~~~~~~~~~~~~~~~~~~~~~~^

C:\AutoIt3\Projects\BMP.au3(325,29) : ERROR: Opt() [built-in] called with wrong number of args.

Local $type=Opt("ColorMode")

~~~~~~~~~~~~~~~~~~~~~~~~~~~^

C:\AutoIt3\Projects\BMP.au3(29,36) : ERROR: BitRotate(): undefined function.

$s2 = BitAND(BitRotate($adler,16)

~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~^

C:\AutoIt3\Projects\BMP.au3(135,42) : ERROR: Floor(): undefined function.

_PixelWrite($BMPHandle,Floor($x-$Width/2)

~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~^

C:\AutoIt3\Projects\BMPDude.au3 - 4 error(s), 0 warning(s)

!>AU3Check ended.rc:2

Any idea what could be causing that?

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
  • Recently Browsing   0 members

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