cancel
Showing results for 
Search instead for 
Did you mean: 
cancel
Showing results for 
Search instead for 
Did you mean: 

Community Tip - You can subscribe to a forum, label or individual post and receive email notifications when someone posts a new topic or reply. Learn more! X

Translate the entire conversation x

How to create a numeric value as a bitmap?

DD_13910355
10-Marble

How to create a numeric value as a bitmap?

I create parametric bitmaps that depend on the values of the calculated variables using the READ_BLUE function.
How to insert a numeric value into such a picture as a bitmap that changes depending on the calculated variables?

ACCEPTED SOLUTION

Accepted Solutions
Werner_E
25-Diamond I
(To:DD_13910355)


@DD_13910355 wrote:

I create parametric bitmaps that depend on the values of the calculated variables using the READ_BLUE function.
How to insert a numeric value into such a picture as a bitmap that changes depending on the calculated variables?


READ_BLUE?

You created a grayscale picture right from scratch.

Is your intention to actually see for instance the x-coordinate "a=30" of the circle center written pixelwise in the picture matrix?

There is no method Mathcad would offer right out of the box, but you sure could write your own.

You would have to create a vector of bitmaps matrices for all letters and numbers first, and then split the number into its individual digits (either by continuously using mod 10 or by turning the number into a string via "num2str" and access the individual characters), select the appropriate bitmap from your vector of  bitmaps, scale it as desired and combine it with the picture bitmap.

Quite some work but sure possible to do. Only worth the effort  if your really need it quite often.

 

How about saving the bitmap to a file with the changing values being part of the file name? Would this help? Or is it mandatory that you actually SEE the numbers (which ones) in the picture?

 

View solution in original post

13 REPLIES 13

Hi,

Add some colour:-

Capture.JPG

Cheers

Terry

Werner_E
25-Diamond I
(To:DD_13910355)


@DD_13910355 wrote:

I create parametric bitmaps that depend on the values of the calculated variables using the READ_BLUE function.
How to insert a numeric value into such a picture as a bitmap that changes depending on the calculated variables?


READ_BLUE?

You created a grayscale picture right from scratch.

Is your intention to actually see for instance the x-coordinate "a=30" of the circle center written pixelwise in the picture matrix?

There is no method Mathcad would offer right out of the box, but you sure could write your own.

You would have to create a vector of bitmaps matrices for all letters and numbers first, and then split the number into its individual digits (either by continuously using mod 10 or by turning the number into a string via "num2str" and access the individual characters), select the appropriate bitmap from your vector of  bitmaps, scale it as desired and combine it with the picture bitmap.

Quite some work but sure possible to do. Only worth the effort  if your really need it quite often.

 

How about saving the bitmap to a file with the changing values being part of the file name? Would this help? Or is it mandatory that you actually SEE the numbers (which ones) in the picture?

 

Hi,

A great Mathcad handbook was released on image creation that has three fonts that can be put into 2D images.

It does exactly as Werner proposed.

 

Capture.JPG

Capture2.JPG

 

Put the images14.hbk file in the C:\Program Files (x86)\Mathcad\Mathcad 15\Handbook directory

Also put the image14 folder into the same directory.

 

Start Mathcad and go to Help | Ebooks | Images 


@terryhendicott wrote:

Hi,

A great Mathcad handbook was released on image creation that has three fonts that can be put into 2D images.

It does exactly as Werner proposed.

Careful!  It is, of course, always worthwhile to take a look at the excellent work of Prof. Byrkeland, but his work deals ‘only’ with classic xy plots,. The fonts he privides in the three "Font0x.xmcd" sheets actually are vector graphics, not pixel graphics as  would be needed in the picture of the questioner.

 

"READ_BLUE?"

I was wrong.

 

 

Werner_E
25-Diamond I
(To:DD_13910355)

I could not be bother to create functions for adding letters and numbers in pixel graphics, but here are some functions which may make it easier to add lines, circles and rectangles (either outlines or filled) in a pixel matrix. The functions were written for grayscale imaged as the one used by you, but could easily be adopted for color images as well. Actually a color image is just a vector consisting of three grayscale images, one for each primary color.

Werner_E_0-1753806478655.png

Other geometric primitives could be added and adding texts may use a similar approach.

 

MC15 sheet attached

 

 

Werner_E
25-Diamond I
(To:DD_13910355)

I could not resist 😉

Here is a basic function to add text to a bitmap graphic.

Werner_E_0-1753839024803.png

Feel free to add bold, italic or rotation.

Because of the 'reversed' x-axis, xpos/ypos denote the position of upper left corner of the text bitmap.

The characters were created by using the screenshot of a text page written in a monospace font.

Word file and screenshot image are attached but not needed for the Mathcad sheet to run. The data is already embedded in the Mathcad sheet.

Initially I used the higher resolution file characters.bmp but autosave (which I have set to activate every few minutes) took quite long and this was annoying. So I used the scaled down characters3.bmp.

 

Hi

It seems the gaming industry uses bitmap fonts for high speed text to monitor pixels so the solutions are available for professional results. One solution that gives any choice of font (TTF etc) and any reasonable size of bitmap font is the online site:

 

https://snowb.org/

 

The product of using the site is twofold. A packed nested image in *.PNG format of the individual charecters, and a text file *.fnt extension giving enough information to unpack individual character bitmaps. The information in a text file is the position in the packed matrix, the size of the character bitmap, and offsets to place the character image into a line of text.

 

To work in Mathcad 15 the PNG file needs to be changed to a BMP file and this is achievable in most graphics programs. I used photoshop saving as a 24 bit BMP.

 

To also work in Mathcad 15 the text file needs to be edited to turn the fnt file into a prn file. First delete the first four lines of headers. Remainder of lines in the fnt file are like this:

 

char id=36 x=60 y=68 width=10 height=15 xoffset=-1 yoffset=-1 xadvance=9 page=0 chnl=15

 

Simply edit/replace "char id=" etc with nothing over the whole file to get:

 

36 60 68 10 15 -1 -1 9 0 15

 

Mathcad 15 can read this file into data By default there are five missing characters when you open the online bitmap font generator. They are "<>\`~" and should be added for Mathcad matrix to be complete. The results are excellent and very professional.

 

Capture.JPG

Cheers

Terry

Cheers

Terry

A great find!
I must admit that I didn't spend too long searching for ready-made bitmap fonts in raw format.

For completeness, and because I enjoy programming for fun.

Here taking Prof. Byrkeland's open shape vector font and turning it into a filled in bitmap.

Capture.JPG

Resulting in, on my not very dense pixel per inch monitor (92 ppi) at 12 points high:-

Capture2.JPG

Cheers

Terry

Thank you! I didn't expect such a deep study of the task.

You are most welcome.

And to finish the study an addText() function as per Werner's approach.

Capture.JPG

Promise this is the last post.

Changed the addText() function to row and column in the larger bitmap for top left corner.

This is more natural.

Capture.JPG

Announcements

Top Tags