Myicq Posted September 11, 2013 Share Posted September 11, 2013 I have a need to create and annotate a (large) BMP file, which needs to be 1bit (only b/w). An example is here The example is 3000x1200, created with PaintShopPro. I would imagine this could be done with one of these tools: ImageMagick (have tried, but I always get a 24 bit image and very small text) GDI+ (new to this one, could not find any examples) FreeImage (not sure about this one) Do anyone have an example of this ? The font and size of demo is not important, I am more interested in the method. Thankful for any pointers in the right direction. I am just a hobby programmer, and nothing great to publish right now. Link to comment Share on other sites More sharing options...
Mat Posted September 11, 2013 Share Posted September 11, 2013 GDI+ is the easiest to use from AutoIt, as there is a standard library which has been tried and tested for years. If you are looking for examples then check the helpfile. A few functions you might want to look at are: _GDIPlus_GraphicsDrawString _GDIPlus_BitmapCreateFromGraphics _GDIPlus_ImageSaveToFile AutoIt Project Listing Link to comment Share on other sites More sharing options...
UEZ Posted September 11, 2013 Share Posted September 11, 2013 Try this: #include <GDIPlus.au3> _GDIPlus_Startup() $hBitmap_1bit = _GDIPlus_BitmapCreateFromScan0(3000, 1200, $GDIP_PXF01INDEXED) $hCtxt = _GDIPlus_ImageGetGraphicsContext($hBitmap_1bit) _GDIPlus_GraphicsClear($hCtxt, 0xFFFFFFFF) _GDIPlus_GraphicsDrawString($hCtxt, "Large image", 100, 200, "Arial", 350) _GDIPlus_GraphicsDispose($hCtxt) _GDIPlus_ImageSaveToFile($hBitmap_1bit, @ScriptDir & "\Bitmap_1bit.bmp") _GDIPlus_BitmapDispose($hBitmap_1bit) ShellExecute(@ScriptDir & "\Bitmap_1bit.bmp") _GDIPlus_Shutdown() Func _GDIPlus_BitmapCreateFromScan0($iWidth, $iHeight, $iPixelFormat = $GDIP_PXF32ARGB, $iStride = 0, $pScan0 = 0) Local $aResult = DllCall($ghGDIPDll, "uint", "GdipCreateBitmapFromScan0", "int", $iWidth, "int", $iHeight, "int", $iStride, "int", $iPixelFormat, "ptr", $pScan0, "int*", 0) If @error Then Return SetError(@error, @extended, 0) If $aResult[0] Then Return SetError(10, $aResult[0], 0) Return $aResult[6] EndFunc ;==>_GDIPlus_BitmapCreateFromScan0 Br, UEZ Please don't send me any personal message and ask for support! I will not reply! Selection of finest graphical examples at Codepen.io The own fart smells best! ✌Her 'sikim hıyar' diyene bir avuç tuz alıp koşma!¯\_(ツ)_/¯ ٩(●̮̮̃•̃)۶ ٩(-̮̮̃-̃)۶ૐ Link to comment Share on other sites More sharing options...
Myicq Posted September 12, 2013 Author Share Posted September 12, 2013 Try this: UEZ, thanks for taking the time to help out. I tried the code, it does make an image in 1 bit, in right size and format. But the image is all black.. which seems strange because you put 0xFFFFFF for white. I will experiment a bit with this starting point. Any other input meanwhile would be great Think I need to dig into and learn GDI+. I am just a hobby programmer, and nothing great to publish right now. Link to comment Share on other sites More sharing options...
UEZ Posted September 12, 2013 Share Posted September 12, 2013 (edited) Seems to be that _GDIPlus_ImageGetGraphicsContext cannot handle this bitmap format under WinXP.Br,UEZ Edited September 12, 2013 by UEZ Please don't send me any personal message and ask for support! I will not reply! Selection of finest graphical examples at Codepen.io The own fart smells best! ✌Her 'sikim hıyar' diyene bir avuç tuz alıp koşma!¯\_(ツ)_/¯ ٩(●̮̮̃•̃)۶ ٩(-̮̮̃-̃)۶ૐ 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