evilertoaster Posted June 8, 2006 Share Posted June 8, 2006 (edited) Hi all, here's a bitmap library with some simple bitmap picture functions.Cheers!(Documentation/example in zip archive also)Updated 6/21/06-v1.2 Added PixelRead and OpenBMP functionsUpdated 6/22/06-v1.3 Added to Help File. Fixed a bug with _OpenBMP(). Added progress bar option as wellUpdated 6/23/06-v1.4 Added to Help File. Fixed another bug with _OpenBMP(). Added _LineWrite()Updated 6/26/06-v1.5 Added to Help File. Rewrote _LineWrite() Function. Color mode now determined by the AutoIt option "ColorMode". Added _CircleWrite() function.Updated 6/30/06-v1.6 Added to Help File. Rewrote _CircleWrite function, now called _EillipseWrite (for a circle have the height and width be the same). Fixed bug in _BMPWrite. Some functions were renamed (this may break any existing code) they are now a more standard format (_ThingAction). Added _RectangleWrite function.Updated 6/30/06(agian)-v1.7 Fixed Bug with BMPOpen. Will no longer try and add-on to already existing files during BMPwrite.Updated 8/14/06-v1.8 Added some fuctions and fixed some bugs. See help file for more info.Updated 2/26/08-v1.9 Updated _BMPWrite to work on the latest version of autoit (I Hope )Updated 3/04/08-v2.0 Significant rewrite of _BMPOpen(),_BMPWrite(),_PixelWrite(),and _PixelRead(). They now work with the native binary variant and binary file I/O. The speed for _BMPOpen() and _BMPCreate() should be significantly faster. _PixelRead() will mostly be unaffected. _PixelWrite() will probably be SLOWER in most cases. I'll leave version 1.9 up in case this becomes an issue for anyone.Updated 5/14/08-v2.1 Fixed a bug when using _BMPOpen() on files with a length or width larger than 255 and added check for BMP size when opening. Removed the check for Opt("ColorMode") as it will be removed from AutoIt soon. Removed some useless code/Slight performence tweaks. Fixed the example file to work 'as is'.Updated 11/01/09-v2.2 Fixed a significant bug with _PixelRead() (Don't know how that slipped by for so long).Updated 11/08/09-v3.0 Significant rewrite of the libraries core functions. Now using DLLStruct functions for pixel reading and writing. A performance gain in almost all cases except for very very small BMPs (<10x10) at which point the speed is almost non-factor. Larger bitmaps like a 1024x768 have performance gains in the order of several magnitudes for pixel writing.There are SCRIPT BREAKING changes to the library. Almost all of the geometric draw functions have been removed (Line write,ellipse write, ect). It was taking the library to a more graphics-driven setting, when it's only intent was to allow pixel I/O. In most cases, you can create design-specific algorithms for drawing functions that were better then the general case ones in the library.Updated 4/14/10-v3.1 Fixed a bug with BMPOpen (Thanks pbsds). Removed the .txt help file, the functions are now documented in the source file with a more standard convention. BMPWrite no longer has the optional 'ProgressBar' parameter.Updated 7/27/10-v3.2 Functions in the library did not have a '_' prefixed to them, now they do...sorry for the flip flop (Thanks loukaniko).Updated 5/01/11-v3.3 Fixed file handle leak in _BMPOpen (Thanks windwind12). Speed improvement (about 25% faster) to _PixelWrite and _PixelRead.BMP_Library1.9.zipBMP_Libary2.2.zipBMP3.3.zip Edited May 1, 2011 by evilertoaster mLipok and genius257 2 Link to comment Share on other sites More sharing options...
ptrex Posted June 8, 2006 Share Posted June 8, 2006 @evilertoaster Great job !! Maybe no one is waiting to create a BMP anymore. But it definitely shows a good example of creating a file using RAWWRITE. This maybe opens the path for creating more formats, apart from BMP ? Contributions :Firewall Log Analyzer for XP - Creating COM objects without a need of DLL's - UPnP support in AU3Crystal Reports Viewer - PDFCreator in AutoIT - Duplicate File FinderSQLite3 Database functionality - USB Monitoring - Reading Excel using SQLRun Au3 as a Windows Service - File Monitor - Embedded Flash PlayerDynamic Functions - Control Panel Applets - Digital Signing Code - Excel Grid In AutoIT - Constants for Special Folders in WindowsRead data from Any Windows Edit Control - SOAP and Web Services in AutoIT - Barcode Printing Using PS - AU3 on LightTD WebserverMS LogParser SQL Engine in AutoIT - ImageMagick Image Processing - Converter @ Dec - Hex - Bin -Email Address Encoder - MSI Editor - SNMP - MIB ProtocolFinancial Functions UDF - Set ACL Permissions - Syntax HighLighter for AU3ADOR.RecordSet approach - Real OCR - HTTP Disk - PDF Reader Personal Worldclock - MS Indexing Engine - Printing ControlsGuiListView - Navigation (break the 4000 Limit barrier) - Registration Free COM DLL Distribution - Update - WinRM SMART Analysis - COM Object Browser - Excel PivotTable Object - VLC Media Player - Windows LogOnOff Gui -Extract Data from Outlook to Word & Excel - Analyze Event ID 4226 - DotNet Compiler Wrapper - Powershell_COM - New Link to comment Share on other sites More sharing options...
evilertoaster Posted June 8, 2006 Author Share Posted June 8, 2006 Yes Bitmap is a very old and reduamentry file format. Not too much use with it for sure. I hope to be able to turn it into a full fleged graphics librbay with support for other formats eventually (maybe a AutoItPaint?^^) but it's a start for now at least like you said. Link to comment Share on other sites More sharing options...
RazerM Posted June 8, 2006 Share Posted June 8, 2006 This is kewl. I didn't think it was this easy. 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. Link to comment Share on other sites More sharing options...
evilertoaster Posted June 21, 2006 Author Share Posted June 21, 2006 Updated- v1.2 Link to comment Share on other sites More sharing options...
CoderDunn Posted June 22, 2006 Share Posted June 22, 2006 Wow I've been waiting for something like this for a while. Really cool. Link to comment Share on other sites More sharing options...
RazerM Posted June 22, 2006 Share Posted June 22, 2006 (edited) Here is an improved example. #include <BMP.au3> $BMP=_MakeBMP(64,64);Create BMP Handle with dimensions 64X64 For $a=0 to 64 _PixelWrite($BMP,$a,$a,"0000FF");BGR _PixelWrite($BMP,$a-1,$a,"0000FF") _PixelWrite($BMP,$a+1,$a,"0000FF") _PixelWrite($BMP,64-$a,$a,"FF0000") _PixelWrite($BMP,64-$a-1,$a,"FF0000") _PixelWrite($BMP,64-$a+1,$a,"FF0000") _PixelWrite($BMP,32,$a,"00FF00") _PixelWrite($BMP,33,$a,"00FF00") _PixelWrite($BMP,$a,32,"00FF00") _PixelWrite($BMP,$a,33,"00FF00") Next _BMPWrite($BMP,@ScriptDir & "\MyBMP.bmp");Closes the BMP to a file GUICreate("BMP Example", 180, 84) GUICtrlCreatePic(@ScriptDir & "\MyBMP.bmp", 58, 10, 64, 64) GUISetState() Do $msg = GUIGetMsg() Until $msg = -3;$GUI_EVENT_CLOSE Your example doesn't work, the white line isn't shown because this line If $BMPHandle[$a][$b]="" Then $BMPHandle[$a][$b]="FFFFFF" makes everything white I added ProgressOff to _BMPWrite and used &= in FixFormat Func _BMPWrite($BMPHandle,$Fpath,$Progress=1) Local $Width=UBound($BMPHandle,1) Local $Height=UBound($BMPHandle,2) Local $FileSize=FixFormat(Hex($Height*$Width*3+54,8)) Local $HexWidth=FixFormat(Hex($Width,8)) Local $HexHeight=FixFormat(Hex($Height,8)) Local $ImageDataSize=FixFormat(Hex($Height*$Width*3,8)) Local $Header="424D"&$FileSize&"000000003600000028000000"&$HexWidth & $HexHeight&"0100180000000000"&$ImageDataSize&"00000000000000000000000000000000" Local $File=FileOpen($Fpath,2) If $File=-1 Then Return (-2) RawWrite($File,$Header) If $Progress=1 Then ProgressOn("Writing BMP File","Line 1 of " & $Height,"",-1,-1,18) Local $a,$b For $a=$Height-1 To 0 Step -1 For $b=0 To $Width-1 If $BMPHandle[$a][$b]="" Then $BMPHandle[$a][$b]="FFFFFF" If RawWrite($file,$BMPHandle[$a][$b])= -1 Then Return (-1) Next If $Progress=1 Then ProgressSet(($Height-$a+1)/$Height*100,"","Line " & $Height-$a & " of " & $Height) Next FileClose($file) ProgressOff() Return 1 EndFunc Func FixFormat($HexData) Local $a,$ReturnValue="" For $a=7 To 1 Step -2 $ReturnValue &= StringMid($HexData,$a,2) Next Return ($ReturnValue) EndFunc Edited June 22, 2006 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. Link to comment Share on other sites More sharing options...
jvanegmond Posted June 22, 2006 Share Posted June 22, 2006 (edited) $BMP=_OpenBMP("MyBMP.bmp") For $x = 0 to UBound($BMP,1)-1 For $y = 0 to UBound($BMP,2)-1 GUICtrlSetGraphic(-1, $GUI_GR_COLOR,Dec($BMP[$x][$y])) _3DDrawPolygon(-1,$x,$y,0) Next Next Edit: Code now works. Other unknown errors occured.. Edit2: The next code has the same error only this is in 2D instead of 3D... Hmm?? $BMP=_OpenBMP("MyBMP.bmp") For $x = 0 to UBound($BMP,1)-1 Step 1 For $y = 0 to UBound($BMP,2)-1 Step 1 GUICtrlSetGraphic(-1, $GUI_GR_COLOR,Dec($BMP[$x][$y])) GUICtrlSetGraphic(-1,$GUI_GR_PIXEL,$x,$y) Next Next Where's the problem? Edited June 22, 2006 by Manadar github.com/jvanegmond Link to comment Share on other sites More sharing options...
evilertoaster Posted June 22, 2006 Author Share Posted June 22, 2006 @RazerM- Ok thanks...I forgot to change the example since 1.0. Do you mind if i use your improved code as the offical release? @Manadar- Let's see...what exactly are you trying to do here? What is the 'error' you're getting? Link to comment Share on other sites More sharing options...
jvanegmond Posted June 22, 2006 Share Posted June 22, 2006 (edited) I seem to be ahead of myself again.. Please run this and you will see my problem. Use any bitmap with it.. I used the one RazorM built in his Example. #include <BMP.au3> #include <GUIConstants.au3> GUICreate("Jingle Bells", 200,200) GUICtrlCreateGraphic(0,0) $BMP=_OpenBMP("MyBMP.bmp") For $x = 0 to UBound($BMP,1)-1 Step 1 For $y = 0 to UBound($BMP,2)-1 Step 1 GUICtrlSetGraphic(-1, $GUI_GR_COLOR,Dec($BMP[$x][$y])) GUICtrlSetGraphic(-1,$GUI_GR_PIXEL,$x,$y) Next Next GUISetState() While 1 If GUIGetMsg() = -3 Then Exit EndIf WEnd Edit: This may cost a lot of CPU power. Increase the stepsize to 2 or 3 and you will still see the problem but use less CPU. Edited June 22, 2006 by Manadar github.com/jvanegmond Link to comment Share on other sites More sharing options...
NELyon Posted June 22, 2006 Share Posted June 22, 2006 Hi all, here's a bitmap library with some simple bitmap picture functions.Right now its only realy function is PixelWrite() but future versions will have more functions.Of course now this means you could do a screen capture nativly by doing PixelGetColor() and _PixelWrite.Right now however it is somewhat slow so things like screen captures with sizes larger than 100x100 may take to long.lmao Link to comment Share on other sites More sharing options...
evilertoaster Posted June 22, 2006 Author Share Posted June 22, 2006 I seem to be ahead of myself again.. Please run this and you will see my problem. Use any bitmap with it.. I used the one RazorM built in his Example.It looks to me like your trying to rewrite the image pixel by pixel? In this case you need to use the provided BMP write funciton. The coordiantes may be stored simply by $BMP[x][y] but thats is not how they are written becuase the BMP file format does not write in the order you'd expect. Take a look at the BMP write function... If you still think there is a problem definatly let me know... (was i coorect in what you were trying to do?) Link to comment Share on other sites More sharing options...
jvanegmond Posted June 22, 2006 Share Posted June 22, 2006 (edited) (was i coorect in what you were trying to do?)That's definately the case. I'm hoping to use this as a way of 'texturing' in my 3D library. Professional texturing is also done with bmp's i believe. Edited June 22, 2006 by Manadar github.com/jvanegmond Link to comment Share on other sites More sharing options...
evilertoaster Posted June 22, 2006 Author Share Posted June 22, 2006 @codemyster- Hey ^^ I'm open to any speed sugestions Link to comment Share on other sites More sharing options...
jvanegmond Posted June 22, 2006 Share Posted June 22, 2006 (edited) evilertoaster.. You're actually saying that, you have no clue on how to build a pixelread function for this? How am i supposed to figure this out if you even can't? *meltdown* [Edit] I will probably write some converter that uses pixelgetcolor and transforms it into a file syntax i will make up. Edited June 22, 2006 by Manadar github.com/jvanegmond Link to comment Share on other sites More sharing options...
evilertoaster Posted June 23, 2006 Author Share Posted June 23, 2006 (edited) Stop the press No Mandar after looking into it more i think it's my problem not yours. There is a bit of a bug with the BMP opening...ill fix it here in a bit... Edited June 23, 2006 by evilertoaster Link to comment Share on other sites More sharing options...
jvanegmond Posted June 23, 2006 Share Posted June 23, 2006 (edited) Stop the press No Mandar after looking into it more i think it's my problem not yours. There is a bit of a bug with the BMP opening...ill fix it here in a bit... I had just developed a AIT file, that basically was this only then very long..: FF0000!FF0000!FFFFFF!FFFFFF!FFFFFF! FF0000!FF0000!FF0000!FFFFFF!FFFFFF! lol ^^ [Edit] Wow it actually worked.. Here's Angelina Jolie as a Texture on a 3D Square. The full 32000 polygons. ( The preview looks like *^$#) Edited June 23, 2006 by Manadar github.com/jvanegmond Link to comment Share on other sites More sharing options...
evilertoaster Posted June 23, 2006 Author Share Posted June 23, 2006 (edited) MK, updated and bug fixed. I was mixing coordinate methods. the write function would write them with (0,0) in the top left and the open function would read pixel (0,0) from the bottom left. Now they both read from the top left like mspaint and autoit. Edit: Cool rendering Manadar...btw whats AIT stand for? Edited June 23, 2006 by evilertoaster Link to comment Share on other sites More sharing options...
jvanegmond Posted June 23, 2006 Share Posted June 23, 2006 (edited) MK, updated and bug fixed. I was mixing coordinate methods. the write function would write them with (0,0) in the top left and the open function would read pixel (0,0) from the bottom left. Now they both read from the top left like mspaint and autoit. Edit: Cool rendering Manadar...btw whats AIT stand for? Nice one i will try it now.. AIT stands for AutoIt Image Texture [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: Edited June 23, 2006 by Manadar github.com/jvanegmond Link to comment Share on other sites More sharing options...
RazerM Posted June 23, 2006 Share Posted June 23, 2006 Yes you can use my code and example for the official release. 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. Link to comment Share on other sites More sharing options...
Recommended Posts
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 accountSign in
Already have an account? Sign in here.
Sign In Now