Jump to content

Creating BMPs with text strings


Myicq
 Share

Recommended Posts

I have seen this question asked (and ) before, but my needs are a little different so I am only 90% of the way. Hope someone can give the final puzzle piece.

Here is what I need:

* from a text file which is Unicode UTF8 (BOM), read strings one by one

* create a BMP file of 300 px high and place textline on it

- BMP must be 2 bit (b/w only)

* save BMP

* read next line

In the end there is as many different BMPs as there are lines in text file.

I know how to operate _GDI_GraphicsDrawstring, that part is simple.

But what I can't find the answer to is

1) how to calculate the space needed horizontally by a given string in 300 px height

2) how to create a white-background BMP in memory, so it can be populated and written to disc.

Point 2) is the most important, the auto-font-size-calculation can come later. For now it's trial and error.

Referring to ImageMagick, this would be

$image->ReadImage('canvas:white');

The purpose is to use images in an industrial microcontroller. Therefore the need for 2bit BMP and 300px exact in height.

Thanks for any help

I am just a hobby programmer, and nothing great to publish right now.

Link to comment
Share on other sites

B&W is 1bpp , not 2 ?

1) Give by Melba23 a try.

2) Create a 1bpp graphics of the required size, draw text inside it and save it as BMP.

Look at (for instance) You don't need much of it but it should have you started. There are many graphics examples around.

This wonderful site allows debugging and testing regular expressions (many flavors available). An absolute must have in your bookmarks.
Another excellent RegExp tutorial. Don't forget downloading your copy of up-to-date pcretest.exe and pcregrep.exe here
RegExp tutorial: enough to get started
PCRE v8.33 regexp documentation latest available release and currently implemented in AutoIt beta.

SQLitespeed is another feature-rich premier SQLite manager (includes import/export). Well worth a try.
SQLite Expert (freeware Personal Edition or payware Pro version) is a very useful SQLite database manager.
An excellent eBook covering almost every aspect of SQLite3: a must-read for anyone doing serious work.
SQL tutorial (covers "generic" SQL, but most of it applies to SQLite as well)
A work-in-progress SQLite3 tutorial. Don't miss other LxyzTHW pages!
SQLite official website with full documentation (may be newer than the SQLite library that comes standard with AutoIt)

Link to comment
Share on other sites

I asked a somewhat related question, and ended up solving it with the help of monoscout999:

I think perhaps you can modify the _GDIPlus_BitmapCreateFromScan0() function to create the base image that you want (see it at the bottom of monoscout999's code).

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

×
×
  • Create New...