Linux bitmap tool

LK/ELK/VK/PK/OK/MX/GLK/EGLK/GVK/GLT Series

Moderators: Henry, Mods

Post Reply
Lynx28
LCD?
Posts: 7
Joined: Sun Jan 23, 2011 9:53 am
Location: Shrewsbury, PA

Linux bitmap tool

Post by Lynx28 »

There isn't a lot of support for the Matrix Orbital displays in a Linux environment, and recently I was trying to find a tool that could be used to create bitmaps. The main problem I ran into is that most graphic tools do way more than necessary. However, there is a bitmap tool (named bitmap) included with x11-apps, and deployed with most distros, that is very basic and can be used to create bitmaps.

The bitmap tool creates an ASCII file (XBM format) with an array of bytes, but needed modification so that the byte array would work for uploads to a GLK display. As a result, I've created a patch that can be used to update bitmap with support for GLK bitmaps.

When looking at the saved image file from bitmap my first thought was that it would be a perfect tool, then I realized that padding is added to lines so that each line would end on a byte boundary. For example, if the image is 12x16 each line is 1.5 bytes, and the tool pads things so that the width is 16 (2 bytes) while keeping what you see 12x16. As mentioned, the image ASCII file contains an array of bytes. However, instead of 24 bytes for a 12x16 image you end up with 32 bytes that includes padding.

The great thing about Linux is that most apps are open source, and you can grab the source and modify code if necessary. As a result, I grabbed the x11-apps source and modified the bitmap app to save a file with the extension glk that contains information you can use to upload the bitmap. Specifically, what I did was add a flag to the "file" menu named "GLK File" that you can toggle on or off. When toggled on it will generate a second file, with the extension .glk, when saving the bitmap. This file contains size, width, height, a byte array, and an upload array that is similar to the one in my GLK19264 Bitmap Upload Sample

I decided to create a .patch of the changes and make this available for anyone who would like to make the update. You'll need to grab the latest source for your distro along with appropriate -dev files and tools ... but it's pretty straight forward.

I'm currently using Ubuntu Maverick ... which is using x11-apps version 7.5+5 ... but I also tested the patch on the latest stable version, which is 7.6+4. It looks like the bitmap code hasn't changed in a while.

At a high level here's the steps to create the patched version of bitmap:
- download and unpack the bitmap.patch.02.tar file attached to this post.
- grab the latest x11-apps source code for your distro.
- install appropriate -dev files and utilities. In my environment I used synaptic package manager and marked libxaw7-dev for installation, which added 12 other -dev packages, next I marked autoconf-archive for install, which contains all of the "auto..." tools needed, and then finally I added xutils-dev. Once all of the packages were installed I had everything needed to build the app.
- you'll also need to install patch

To apply the patch:
- extract the bitmap source folder from the x11-apps tar.gz.
- copy bitmap.patch into the bitmap source folder
- cd into the bitmap source folder
- execute: patch -p1 -i bitmap.patch

If everything worked you'll see that five files have been patched: app-defaults/Bitmap, bitedit.c, bitmap.c, bitmap.h, bitmapP.h

Once the patch has been applied, execute:
sh autogen.sh (which also executes ./configure)
make

Instead of using "make install" I renamed the original file in /usr/bin and then copied the new one into /usr/bin. you can also run it from the bitmap folder where you built the file, it's up to you.

If you want Ctrl-G support for the new GLK File option, you'll also need to update the Bitmap file in /etc/X11/app-defaults (Ubuntu). This file is updated with the patch and would be deployed with "make install". It's actually a pretty cool file that lets you modify labels, key mappings, and other options associated with the bitmap app.

Hopefully this helps someone, I'm also working on a utility that will upload the bitmap files created from bitmap directly to a GLK19264, which should work for most GLK devices

EDIT: I decided to move the "GLK File" option to the file menu... makes more sense there... and I also added support for Ctrl-G to toggle the flag. This is done with an update to the app-defaults/Bitmap file. In Ubuntu this file is located in /etc/X11/app-defaults it might be in another location on other distros. I've tested the patch and deployed the update to my /usr/bin and /etc/X11/app-defaults folders.


--Lonnie (Lynx28)
Attachments
bitmap.patch.02.tar
Linux patch file for the x11-apps bitmap application. Includes patch to app-defaults/Bitmap
(20 KiB) Downloaded 413 times
Last edited by Lynx28 on Thu Mar 24, 2011 7:30 am, edited 3 times in total.

Julian
Matrix Orbital
Matrix Orbital
Posts: 61
Joined: Thu Sep 06, 2001 6:00 pm
Location: Calgary, Ab, Canada

Post by Julian »

Thanks for a great post, we've had a lot of questions about using our displays in linux in the past few weeks, hopefully this helps some people out!

Post Reply