AutoHotkey Community

It is currently May 27th, 2012, 8:23 am

All times are UTC [ DST ]




Post new topic Reply to topic  [ 13 posts ] 
Author Message
PostPosted: February 15th, 2009, 4:32 pm 
Offline
User avatar

Joined: May 5th, 2007, 7:24 pm
Posts: 1240
Location: Seville, Spain
EasyBMP - Extremely tiny BMP manipulation DLL based on a powerful C++ BMP library

Version 1.2

Hi, I present you my newest creation!
It's a DLL that allows you to manipulate BMP files.
It is based on the C++ BMP library of the same name (link).
The total size of the DLL is 28 KB :!:
Features:
  • Load and save uncompressed BMPs.
  • Plot pixels, draw lines, rectangles, circles, arcs and text.
  • Copy image blocks with transparent color support and fill image regions with colors.
  • Get pixel colors.
  • Set/get bit depth, DPI (dots per inch) support.
  • Image resizing.
  • Anti-aliasing for the drawing and bilinear filtering for the resizing.
  • Display images in Text or Picture controls without temporary files.
  • Take screenshots of the screen and particular windows.

Works with any Windows version (9x/ME/NT/2000/XP/Vista/7).

What are you waiting for?
Download - Documentation

Changelog:

v1.2: Numerous bugfixes in the EasyBMP C++ library (yes, it was buggy!) related to the alpha channel. Made the DLL smaller. Bugfixes on the AHK wrapper, a typo.
v1.1: Added BMP_FillBlock() function, fixed a memory-wasting bug in the DLL. Made examples of every function.
v1.0: Initial release.

Coming soon: Embedded DLL inside script that will be extracted on run-time.

_________________
fincs
Highly recommended: AutoHotkey_L (see why) (all my code snippets require it)
Formal request to polyethene - I support the unity of the AutoHotkey community
Get SciTE4AutoHotkey v3.0.00 (Release Candidate)
[My project list]


Last edited by fincs on February 15th, 2009, 10:55 pm, edited 5 times in total.

Report this post
Top
 Profile  
Reply with quote  
 Post subject:
PostPosted: February 15th, 2009, 7:44 pm 
Offline
User avatar

Joined: May 5th, 2007, 7:24 pm
Posts: 1240
Location: Seville, Spain
28 views and no reply yet?

_________________
fincs
Highly recommended: AutoHotkey_L (see why) (all my code snippets require it)
Formal request to polyethene - I support the unity of the AutoHotkey community
Get SciTE4AutoHotkey v3.0.00 (Release Candidate)
[My project list]


Report this post
Top
 Profile  
Reply with quote  
 Post subject:
PostPosted: February 15th, 2009, 7:48 pm 
Offline

Joined: March 10th, 2008, 12:55 am
Posts: 1907
Location: Minnesota, USA
28 views isn't much. Neither is 3 hours. People have lives other then PC/AHK. Be patient.

_________________
rawr. be very afraid
*poke*
Note: My name is all lowercase for a reason.
"I think Bigfoot is blurry, that's the problem. It's not the photographer's fault, Bigfoot is blurry. So there's a large, out-of-focus monster roaming the countryside."


Report this post
Top
 Profile  
Reply with quote  
 Post subject:
PostPosted: February 15th, 2009, 9:50 pm 
Offline
User avatar

Joined: December 21st, 2007, 3:14 pm
Posts: 3826
Location: Louisville KY USA
tidbit wrote:
People have lives other then PC/AHK. Be patient.
We DO :?:

_________________
No matter what your oppinion Please join this discussion
Formal request to Polyethene
Image


Report this post
Top
 Profile  
Reply with quote  
 Post subject:
PostPosted: February 15th, 2009, 10:17 pm 
Offline
User avatar

Joined: May 5th, 2007, 7:24 pm
Posts: 1240
Location: Seville, Spain
Version 1.2 released which does bugfixes to the base EasyBMP C++ library and thus the DLL.

EDIT: Uploaded a more compact DLL.
EDIT2: Uploaded a version of the AHK wrapper without a typo :roll:

_________________
fincs
Highly recommended: AutoHotkey_L (see why) (all my code snippets require it)
Formal request to polyethene - I support the unity of the AutoHotkey community
Get SciTE4AutoHotkey v3.0.00 (Release Candidate)
[My project list]


Report this post
Top
 Profile  
Reply with quote  
 Post subject:
PostPosted: February 16th, 2009, 1:35 am 
There are some (500+) typos on your documentation. In the related links, each one on each page starts with ".\" which causes you to link to a missing file.


Report this post
Top
  
Reply with quote  
 Post subject:
PostPosted: February 16th, 2009, 1:36 am 
~Trikster wrote:
There are some (500+) typos on your documentation. In the related links, each one on each page starts with "." which causes you to link to a missing file.


Edit: Sorry, this only occurs in Firefox 3.0.6. It works fine in Chrome.


Report this post
Top
  
Reply with quote  
 Post subject:
PostPosted: February 16th, 2009, 5:38 pm 
Offline
User avatar

Joined: September 8th, 2008, 12:26 am
Posts: 1048
Location: Ploieşti, RO
Well, the example does create and display a screenshot (for primary monitor only; please note I use dual-view), however the resulting screenshot is a 32bit bitmap that Win9x - or better said, certain image-manipulating apps - may not be very fond of. Is there a way to specify colour depth (at least 24/32bit)?

Tested in Win98SE.

This might be useful to simulate the Superbar behavior of Window 7 in Win9x... if anybody feels the urge to. Could also be of help in the DM2 project, since its native screenshot feature doesn't currently work in 9x. :D

Thank you, fincs! 8)

_________________
AHK tools by Drugwash (AHK 1.0.48.05 and Win98SE)


Report this post
Top
 Profile  
Reply with quote  
 Post subject:
PostPosted: October 14th, 2010, 11:11 pm 
Offline

Joined: October 14th, 2010, 12:37 pm
Posts: 3
Cool stuff. I'm using it currently with Sparrow for some basic Captcha generation (random name generator script from this forum as a word creating module).


All files + noise.bmp
I could write a function to make a noise, but with my abilities it would take even longer to generate captcha ;P

http://www.autohotkey.net/~plenty/captcha/captcha.rar



Code:
SetWorkingDir %A_ScriptDir%

#include EasyBMP.ahk

EasyBMP_Init()
rc := EasyBMP_Init() ; initializes EasyBMP
If !rc
{
   MsgBox, 16,, Error initializing EasyBMP!
   ExitApp
}

Random, , A_MSec

hBMP1 := BMP_Create()
BMP_Set(hBMP1, "size", 300, 60)

Text4bmp:=RandomName(4, 8)
Text_DrawString(hBMP1, "x8 y10", Text4bmp, 40, "0x000000BB")
Text_DrawString(hBMP1, "x13 y10", Text4bmp, 40, "0x000000BB")
Text_DrawString(hBMP1, "x10 y10", Text4bmp, 40, "0x00FF00BB")
Text_DrawString(hBMP1, "x11 y10", Text4bmp, 40, "0x0000FFBB")
Text_DrawString(hBMP1, "x10 y11", Text4bmp, 40, "0xFF0000BB")
Text_DrawString(hBMP1, "x9 y10", Text4bmp, 40, "0x0FF000BB")
Text_DrawString(hBMP1, "x12 y10", Text4bmp, 40, "0x000FF0BB")
Text_DrawString(hBMP1, "x9 y9", Text4bmp, 40, "0x0FF000BB")
Text_DrawString(hBMP1, "x12 y11", Text4bmp, 40, "0x000FF0BB")

;stamp:=x30 y30 w300 h60
hBMP2 := BMP_Create()
BMP_LoadFile(hBMP2, "noise.bmp") ; loads the file noise.bmp into hBMP2.
BMP_GetInfo(hBMP2, noiseW, noiseH)
rangeX:=noiseW-300
rangeY:=noiseH-60

Random, x, 0, rangeX
Random, y , 0, rangeY
randompos=x%x% y%y% w300 h60
BMP_CopyBlock(hBMP2, randompos, hBMP1, "x0 y0", "white")

Random, x, 0, rangeX
Random, y , 0, rangeY
randompos=x%x% y%y% w300 h60
BMP_CopyBlock(hBMP2, randompos, hBMP1, "x0 y0", "white")


BMP_Set(hBMP1, "bitdepth", 4) ;sets 4 bit (16 colors)  to reduce output size (works only if there are no more than 16, otherwise, i think, it defaults to 32 bits)
BMP_SaveFile(hBMP1, "captcha.bmp")



EasyBMP_DeInit()

ExitApp


RandomName(MinLength=4, MaxLength=8)
{   

   ;This is a table of probabilities of given letter combinations.
   ;Each list is the probability of any letter coming after the letter that is the variable name.
   ;The 27th value is the probability that the word ends with the current letter.

   A=0.005129|0.020532|0.038276|0.031753|0.005903|0.009913|0.027038|0.014457|0.023527|0.003511|0.021702|0.086397|0.045315|0.192551|0.002685|0.014491|0.001136|0.142056|0.059445|0.043698|0.041322|0.018312|0.010774|0.001824|0.020584|0.010240|0.107428
   B=0.184518|0.021072|0.000500|0.002564|0.243982|0.000125|0.000188|0.002564|0.076033|0.001313|0.001563|0.055274|0.000875|0.002376|0.132933|0.000063|0.000000|0.133683|0.009192|0.000313|0.090977|0.000188|0.000125|0.000000|0.022447|0.000313|0.016820
   C=0.131713|0.001253|0.042204|0.003536|0.053348|0.001566|0.008727|0.275689|0.051557|0.000090|0.154493|0.028375|0.003849|0.004117|0.123255|0.001343|0.002954|0.036744|0.002506|0.003043|0.028419|0.000806|0.001343|0.000000|0.004699|0.017678|0.016694
   D=0.103809|0.005881|0.001079|0.024765|0.256609|0.003345|0.017266|0.006367|0.102029|0.000701|0.002968|0.027085|0.008849|0.007985|0.107424|0.000432|0.000432|0.046833|0.019208|0.017427|0.044783|0.001619|0.007068|0.000000|0.020557|0.005288|0.160192
   E=0.031341|0.012931|0.019802|0.020976|0.022773|0.007726|0.014163|0.010930|0.034414|0.002392|0.012409|0.104894|0.023455|0.108561|0.004291|0.007973|0.000464|0.239084|0.062957|0.042633|0.006958|0.011727|0.010582|0.001363|0.039371|0.008379|0.137452
   F=0.111275|0.000369|0.000985|0.000246|0.170236|0.139463|0.000985|0.000985|0.112752|0.000492|0.003570|0.058961|0.004677|0.004677|0.114476|0.000246|0.000123|0.100197|0.011324|0.021295|0.041113|0.000369|0.000246|0.000000|0.003570|0.000862|0.096504
   G=0.140257|0.004596|0.000919|0.003493|0.199694|0.002145|0.030944|0.064951|0.064767|0.000551|0.000919|0.053922|0.006311|0.020282|0.084191|0.000551|0.000368|0.083027|0.019179|0.012316|0.063725|0.000797|0.004718|0.000245|0.003309|0.000123|0.133701
   H=0.214954|0.004703|0.001599|0.001035|0.189466|0.002116|0.000564|0.002069|0.102610|0.000658|0.003621|0.037903|0.020973|0.022384|0.124759|0.000329|0.000000|0.032683|0.006207|0.021067|0.054221|0.000517|0.009358|0.000000|0.009828|0.000141|0.136233
   I=0.044717|0.012847|0.076362|0.026840|0.088736|0.009884|0.035604|0.003560|0.000896|0.001320|0.015511|0.082586|0.027886|0.216811|0.031571|0.012474|0.001270|0.031247|0.081889|0.054502|0.004158|0.011802|0.001494|0.002938|0.001245|0.009262|0.112588
   J=0.333844|0.000510|0.012251|0.006126|0.211843|0.000000|0.001021|0.003063|0.059214|0.001021|0.010720|0.002552|0.003063|0.009188|0.197550|0.000000|0.000000|0.000000|0.002552|0.007657|0.110260|0.000000|0.001021|0.000000|0.000510|0.001531|0.024502
   K=0.105301|0.002453|0.000239|0.000658|0.194089|0.001615|0.000120|0.013522|0.166507|0.000838|0.003889|0.046787|0.009633|0.017470|0.101412|0.000299|0.000060|0.036078|0.023932|0.001137|0.039069|0.000897|0.004786|0.000239|0.025009|0.000179|0.203781
   L=0.142144|0.012700|0.007785|0.033484|0.190748|0.007136|0.004641|0.004666|0.115222|0.000499|0.010554|0.157140|0.017815|0.003019|0.079568|0.004042|0.000549|0.002146|0.023429|0.022031|0.025599|0.007884|0.002770|0.000075|0.015320|0.004292|0.104743
   M=0.313971|0.039109|0.071357|0.001102|0.144316|0.001552|0.001502|0.001252|0.093991|0.000300|0.003756|0.007561|0.032849|0.001753|0.110366|0.030796|0.000451|0.004507|0.016475|0.000701|0.039509|0.000150|0.001052|0.000000|0.007161|0.000801|0.073660
   N=0.061413|0.016703|0.021091|0.069684|0.122481|0.004871|0.078736|0.008455|0.062562|0.000942|0.020976|0.004802|0.002481|0.042114|0.058036|0.001011|0.000712|0.003538|0.053877|0.050017|0.007168|0.001746|0.003331|0.000000|0.007099|0.011970|0.284182
   O=0.008524|0.017299|0.028237|0.027181|0.024717|0.015061|0.013377|0.013477|0.008725|0.002338|0.011843|0.083101|0.033291|0.169068|0.030248|0.016394|0.000654|0.114958|0.060421|0.038018|0.047975|0.020140|0.041337|0.002791|0.010611|0.008725|0.151492
   P=0.176699|0.000875|0.001459|0.000972|0.201984|0.015365|0.000292|0.038802|0.113099|0.000097|0.010503|0.051055|0.002334|0.003209|0.103958|0.076145|0.000000|0.074492|0.021103|0.010114|0.033064|0.000194|0.000875|0.000000|0.007002|0.000097|0.056209
   Q=0.006831|0.001366|0.000000|0.001366|0.000000|0.000000|0.000000|0.000000|0.005464|0.000000|0.000000|0.000000|0.000000|0.000000|0.000000|0.000000|0.000000|0.001366|0.000000|0.000000|0.968579|0.001366|0.000000|0.000000|0.000000|0.000000|0.013661
   R=0.107889|0.012734|0.012774|0.039466|0.114066|0.005515|0.027955|0.005334|0.100509|0.000762|0.014499|0.017507|0.018449|0.029038|0.095937|0.004171|0.001043|0.037882|0.037180|0.049252|0.031785|0.005475|0.003068|0.000160|0.020154|0.005715|0.201681
   S=0.063337|0.009701|0.073814|0.002910|0.097763|0.001774|0.001525|0.060925|0.050808|0.000554|0.061286|0.020318|0.015134|0.008482|0.067384|0.021426|0.002328|0.001663|0.053885|0.132300|0.016797|0.001247|0.011808|0.000000|0.003964|0.007429|0.211437
   T=0.091587|0.001630|0.012519|0.000347|0.159384|0.001595|0.001769|0.072652|0.074005|0.001283|0.006208|0.018484|0.009294|0.007352|0.110522|0.000555|0.000069|0.065543|0.026564|0.109169|0.024691|0.000763|0.005098|0.000000|0.013525|0.036447|0.148946
   U=0.021849|0.032911|0.052449|0.040176|0.074243|0.017281|0.047056|0.012163|0.041827|0.002862|0.015190|0.084205|0.058118|0.084810|0.006219|0.021354|0.001101|0.136984|0.111833|0.065658|0.000881|0.005449|0.002367|0.008806|0.007320|0.013979|0.032911
   V=0.281558|0.000162|0.000647|0.001293|0.327461|0.000162|0.000323|0.000162|0.251657|0.000485|0.001616|0.010991|0.000162|0.003071|0.078390|0.000000|0.000000|0.012769|0.007435|0.000323|0.004687|0.000162|0.000323|0.000000|0.007112|0.000485|0.008566
   W=0.204323|0.006032|0.003770|0.009801|0.191380|0.000880|0.001131|0.037824|0.200804|0.000000|0.005278|0.018472|0.003644|0.016210|0.092109|0.000377|0.000126|0.013948|0.074265|0.004398|0.007665|0.000628|0.000628|0.000000|0.015582|0.000628|0.090098
   X=0.063694|0.022293|0.004777|0.001592|0.081210|0.012739|0.000000|0.011146|0.065287|0.000000|0.001592|0.039809|0.014331|0.014331|0.044586|0.001592|0.000000|0.004777|0.033439|0.078025|0.007962|0.000000|0.014331|0.003185|0.004777|0.001592|0.472930
   Y=0.061443|0.012165|0.011753|0.016289|0.072062|0.003505|0.004845|0.004845|0.003505|0.000206|0.016907|0.026495|0.018763|0.042268|0.032680|0.003711|0.000206|0.014330|0.026186|0.011856|0.008763|0.001443|0.004021|0.000206|0.000412|0.002887|0.598247
   Z=0.165246|0.006787|0.005366|0.004261|0.174085|0.000947|0.004261|0.003946|0.121370|0.000000|0.014205|0.018466|0.017045|0.009154|0.066761|0.000789|0.001578|0.001578|0.004104|0.000631|0.035827|0.000631|0.008996|0.000000|0.034722|0.058396|0.240846
   Start=0.037129|0.091544|0.068008|0.055260|0.020789|0.036464|0.052670|0.058435|0.006802|0.012894|0.051228|0.053638|0.085992|0.020597|0.016318|0.052275|0.002725|0.047647|0.109494|0.038852|0.004460|0.023480|0.036127|0.000180|0.006261|0.010732
   

   ;This allows numerical values to easily be converted to letters.
   Alphabet = ABCDEFGHIJKLMNOPQRSTUVWXYZ
   
   Loop
   {
      ;Checks for the previous letter to determine which set of probabilities to use.
      If (!Word)
         Previous = Start
      Else
         Previous := SubStr(Word, 0, 1)


      ;Randomly chooses the next letter, based on the probabilities listed above.
      Random, rand, 0.0, 1.0
      Sum = 0
      Next =
      Loop, parse, %Previous%, |
      {
         Sum += A_LoopField
         If (rand<Sum)
         {
            Next := SubStr(Alphabet, A_Index, 1)
            Break
         }
      }


      ;Finishes the word if the word randomly ends or reaches the maximum length.
      If ((!Next AND StrLen(Word)>=MinLength) OR (MaxLength AND StrLen(Word)=MaxLength))
         Break
   
      Word .= Next
   }
   
   StringUpper, Word, Word
   Return, Word
}




Hope it will be useful for sparrow users.


Report this post
Top
 Profile  
Reply with quote  
PostPosted: February 2nd, 2012, 6:28 pm 
Offline

Joined: February 2nd, 2012, 6:21 pm
Posts: 2
Location: Los Angeles, CA
fincs wrote:
EasyBMP - Extremely tiny BMP manipulation DLL based on a powerful C++ BMP library

Version 1.2

Hi, I present you my newest creation!
It's a DLL that allows you to manipulate BMP files.
It is based on the C++ BMP library of the same name (link).
The total size of the DLL is 28 KB :!:
Features:
  • Load and save uncompressed BMPs.
  • Plot pixels, draw lines, rectangles, circles, arcs and text.
  • Copy image blocks with transparent color support and fill image regions with colors.
  • Get pixel colors.
  • Set/get bit depth, DPI (dots per inch) support.
  • Image resizing.
  • Anti-aliasing for the drawing and bilinear filtering for the resizing.
  • Display images in Text or Picture controls without temporary files.
  • Take screenshots of the screen and particular windows.
Works with any Windows version (9x/ME/NT/2000/XP/Vista/7).

What are you waiting for?
Download - Documentation

Changelog:

v1.2: Numerous bugfixes in the EasyBMP C++ library (yes, it was buggy!) related to the alpha channel. Made the DLL smaller. Bugfixes on the AHK wrapper, a typo.
v1.1: Added BMP_FillBlock() function, fixed a memory-wasting bug in the DLL. Made examples of every function.
v1.0: Initial release.

Coming soon: Embedded DLL inside script that will be extracted on run-time.


This is very cool. I'd be interested in the bugs you mentioned in your later post--I'd want to update EasyBMP to fix them.

Thanks -- Paul


Report this post
Top
 Profile  
Reply with quote  
 Post subject:
PostPosted: February 2nd, 2012, 6:32 pm 
Offline
User avatar

Joined: May 5th, 2007, 7:24 pm
Posts: 1240
Location: Seville, Spain
This is ridiculously outdated & doesn't work with the latest version of AHK. I'd suggest you use GDI+ instead.

_________________
fincs
Highly recommended: AutoHotkey_L (see why) (all my code snippets require it)
Formal request to polyethene - I support the unity of the AutoHotkey community
Get SciTE4AutoHotkey v3.0.00 (Release Candidate)
[My project list]


Report this post
Top
 Profile  
Reply with quote  
 Post subject:
PostPosted: February 2nd, 2012, 6:36 pm 
Offline

Joined: February 2nd, 2012, 6:21 pm
Posts: 2
Location: Los Angeles, CA
fincs wrote:
This is ridiculously outdated & doesn't work with the latest version of AHK. I'd suggest you use GDI+ instead.


That would certainly make sense for windows-only users (who would be using the DLL anyway.) Sorry I didn't notice the old dates in the original post. :-/

However, if you did find mistakes in the core library, I'd appreciate hearing them so I can fix them in EasyBMP (for use on all the other platforms).

All the best -- Paul (of easybmp.sf.net)


Report this post
Top
 Profile  
Reply with quote  
 Post subject:
PostPosted: February 2nd, 2012, 7:45 pm 
Offline
User avatar

Joined: May 5th, 2007, 7:24 pm
Posts: 1240
Location: Seville, Spain
macklin01 wrote:
fincs wrote:
This is ridiculously outdated & doesn't work with the latest version of AHK. I'd suggest you use GDI+ instead.


That would certainly make sense for windows-only users (who would be using the DLL anyway.) Sorry I didn't notice the old dates in the original post. :-/

However, if you did find mistakes in the core library, I'd appreciate hearing them so I can fix them in EasyBMP (for use on all the other platforms).

All the best -- Paul (of easybmp.sf.net)


So you're the original EasyBMP developer :shock:

IIRC, EasyBMP forgot to update the alpha channel too when doing some operations. I just blew the dust off my local copy of the source code & made a patch. It applies to a folder containing both EasyBMP and the EasyBMP extension package. Feel free to do anything you like with my changes.

_________________
fincs
Highly recommended: AutoHotkey_L (see why) (all my code snippets require it)
Formal request to polyethene - I support the unity of the AutoHotkey community
Get SciTE4AutoHotkey v3.0.00 (Release Candidate)
[My project list]


Report this post
Top
 Profile  
Reply with quote  
Display posts from previous:  Sort by  
Post new topic Reply to topic  [ 13 posts ] 

All times are UTC [ DST ]


Who is online

Users browsing this forum: AndyJenk, Aravind, Bing [Bot], Google Feedfetcher, Stigg and 10 guests


You can post new topics in this forum
You can reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot post attachments in this forum

Search for:
Powered by phpBB® Forum Software © phpBB Group