Evropski sklad za regionalni razvoj

ArahPaint 2.8e source (Outdated)


If you want to learn about ArahPaint capabilites from the user’s point of view, read the User’s Manual. If you want a quick overview of its capabities with screenshots, look at this page. If you like what you see and would like to use it, without recompiling it, take the binary built for Linux from hereArahPaint is included with the distribution of ArahWeave DEMO. The information presented here is intended for programmers, who want to understand how (and why) was this program done. If you are a normal user, you will be only confused it you read this page.

This program was developed in a commercial setup, as part of a package for jacquard fabric design. We wanted a clear separation between creative design phase and technical weaving phase, so we developed ArahPaint as a separate paint module.

This is a PAINT program, as its name implies. This means it deals with pixels, not vector based images. Images are internally treated always in 8 bits per pixel (up to 256 colors). This means that bilevel images will be expanded to 8 bits per pixel, while true color (24 bits per pixel) images will be reduced to 8 bits per pixel, without any dithering. Program supports a palette of 16 million colors, but does not support named colors or any colorimetry. It does not support palettes as a separate entity – palette colors are always sorted based on color popularity, after each loading of an image.

Program works on graphics displays with 8/16/24/32 bits per pixel, but will always operate in the way described above. The advantage of having a screen with more than 8 bits per pixel is, that you do not have any colormap limitations – you can contemporary run as many programs as you like, as long as you do not run out of memory. On 8 bits per pixel, you will soon run out of free colors, since all the programs together, including desktop, can use only up to 256 colors.

The reasons for these conceptual choices are rooted in the program’s primary use – jacquard fabric design. So this is not a photo-retouching program like GIMP, and will never be. Trying to change this basic arhitecture would be futile, since it would involve a complete rewrite of the program.

ArahPaint is intentionally feature-poor. It was our objective to make it flexible and powerful, but with as few tools as possible. Many of our customers are first-time computer users, and we could never train them into using an ultra powerful feature-packed tool like GIMP. In GIMP, some difficult operations are very easy, but some very easy operations are almost impossible.

ArahPaint needs to do only a few things, but do them well. Another difference to yet-another-paint-programwritten by first year CS student, and abandoned after one year, is the treatment of big images. Most naive programs allocate pixmap in the full size of the image, to do the drawing operations. This may work nicely on 400×400 images, but tends to create problems if your image is 10000×10000. Experienced users know, that making X-large pixmaps can put your X Server in tilt, in spite of Linux/Unix reputation of being rock solid. Or maybe the underlying Linux will still work flawlessly, just that user will not be able to move the mouse, switch virtual terminals or quit X session. It is comforting to know that down there something works, but it does not really help.

ArahPaint is not a fabulous program for freehand design, since it is mainly aimed at cleaning up scanned images. That is: reducing number of colors and getting clear flat areas of single color, in the right x/y ratio, size and number of colors, as technically necessary for the weaving of the fabric. In jacquard fabric design, you only need clear distinctive areas of single color, which will be later replaced with the weaves. The final aspect of the fabric depends both on weaves as on yarns, fabric density, etc. Therefore, the colors in ArahPaint are not important, as long as they are distinctive. This explains the lack of colorimetry and named colors. Program can be misused for design of patterns intended for printing (paper or textile), but the above limitations will make it useful only in some specific cases, where image consists of flat non-overlappnig areas.

So after all these things which the program does not do – what does it do? It is very good at color reduction and offers great user control at it. It is also useful at putting the image in repat. It permits drawing across borders of repeat, and supports sophisticated motif drop modes. It allows zoom with user-specifiable x:y point ratio. This is crucial for jacquard fabric design, where images are squashed due to technical weaving reasons (different density of fabric in warp and in weft). In jacquard fabric, every point makes a difference in the final quality of the fabric, so we have good tools for drawing in zoom and fixing contours. Note that in fabric design, image starts from the bottom, so coordinates in ArahPaint also work in this way.

Why Open Source?

You can read on our home page that we do not believe that niche applications like ours can be open source. There is no business model which would support it. If there is, we would like to know about it and make a fortune 😉

So why are we doing it, anyway? Because we have always relied on work of others, either in form of books or source code released their authors. Our program is also reasonably small, since we can dynamically link many external LGPL libraries, which we could never write ourselves. We always had some bad conscious about that, and now we can give something back to the community.

We can release ArahPaint because we have kept closed source the jewels of the family: ArahWeave, which contains colorimetry, jacquard interfaces and a lot of weaving specific code. We have also uncoupled loading and printing/saving code from ArahPaint into separate libraries, so that we could easily remove loaders which are covered by non-disclosure agreements or patents.

Of course, ArahPaint also contains some pearls, but we will leave that to the people who will really take time to look at the source.

Why should you look at this code? You can learn about OSF/Motif programming, graphics programming, printer drivers, dithering, 6-color color separation, image loaders, contour operators, faster image refresh with the use of MIT-SHM extension, to name a few.

Now, that it was released – is it actually AbandonWare®? No, we will continue with our normal (slow) developement. If we receive any useful code contributions, we will be glad. But if not, we will not despair.

We would also like to support LessTif, a freeware Motif clone. At the time of writing, the compatibility is not yet 100%, and by releasing the source code we hope it will be easier for the developers to iron out the remaining differences. LessTif effort has been “rewarded” in May 2000 by opening of the original Motif source for free operating systems like Linux. But OpenMotif is not GPL and many people think LessTif should continue its effort. So we support it out of respect for their work, even if does not have a big practical value for Arahne.

Then, we also make it open source because it is a nice little program, self contained, only 20.000 lines of code. It doesn’t take a rocket scientist to figure out what is it doing, and even beginners can tinker with it. If Mozilla does not fit on your hard disk, or you do not have one month to figure out which file is doing what – you can start with ArahPaint.

As always, there is a vested interest behind all this… ArahPaint is a companion program to ArahWeave, integrated dobby and jacquard CAD/CAM program. There may not be so many weavers left in this world, but there are still many people who need a small paint program for simple tasks from time to time. And maybe you have a friend who does textile design, and you can show them both ArahPaint and ArahWeave. Weavers will be quick to understand the true value of ArahWeave, and that is all we need.

We are also concerned with the fact, that our existing customers, who have paid for the development of this program, might be upset. Why should everyone else get for free what they have recently paid? We hope we have something for them, too. Namely, due to the nature of jacquard work, users spend 90% of their time in ArahPaint, cleaning up the artwork. The remaining 10% is done in ArahWeave by replacing the colors in the image with the weaves, making a fabric simulation, and the file in desired electronic jacquard format. So from now on, they will be able to install ArahPaint at home and do some “homework”, if necessary.

A Note on Style

As you will notice if you check the code, the program is not a marvel of software engineering and consistent style. You will see variable naming inconsistency, lots of global variables, different indenting styles, and different approaches to solve similar problems.

It is a work of two programmers, who did not always get along on the style issues, and given many other things to do, re-writing and clearing style inconsistencies never made it to the top of TO-DO list. Since the program basically works, and that we still manage to fix its bugs and add new features, there is not enough pressure to fix those things. When the program development started, we did not think of open source or anything like that. So many of the comments and variable names used to be in the Slovenian language, since Slovenia is the country of origin of this software. We have “cleaned” most of Slovenian language from the source, but there might be some remains of the old days, so you know what it is, when you do not understand a thing…

A Note on Portability

We have started this project many years ago with very high hopes for the portability. The development started on Consensys Unix 4.2, and passed its different incarnations to Novell UnixWare 1.0 and then to SCO UnixWare 2.0. We were also doing regular ports to Silicon Graphics, to fix at least some portability issues.

We have even ported it to NT using Softway’s OpenNT (then renamed to Interix, now owned by Microsoft). Unfortunatelly, the result was not stable enough, executable was very big, since dynamic libraries were not suppored, the Motif’s look and feel did not fit very nice in Windows NT, and there were run time licenses involved. In the real life, however, portability and platform independance never proved to be a big selling point. Our market are texile weaving mills, who are generally very price cautious and will always go for the cheapest patform. Given a choice of 2.000 USD PC and 10.000 USD workstation, they did not think twice.

About 4 years ago, just prior to release of UnixWare 7, UnixWare became almost impossible to install on any graphics card still on the market, for every release we had to install tens of megabytes of updates and PTFs to make system useful. At the same time, Linux got quite stable, its support of hardware became far superior to any commercial PC Unix, and you were able to buy it just behind any corner. The release cycle was also shorter, and the price could not be better. So it was natural to switch to Linux, and our multi-platform development model has considerably reduced porting effort.

On Linux, we still had some problems due to transition from a.out to elf libraries, libc5 to glibc, jpeg6a to jpeg6b, but this should be settled now. And with the release of free OpenMotif for Linux, things could not be better. So Linux on Intel PC (or Lintel, as it is called nowadays) is our primary platform, and the only one we are really interested in. We will still try to follow standards (ANSI C, X11 R6.3, OSF/Motif 2.1), and provide portable solution whenerver we can, but we do not have the resources to test the program on different platforms, and we have no intention of supporting them. We will be happy to learn that program also runs on some exotic machine, but we will accept portability fixes only if they can be cleany integrated into single source.


We provide just one big tarball, which contains the code written by Arahne:

Program also relies on a number of libraries, but we only provide the one which is not widely used. It is called Widget Construcion Library developed by David E. Smyth.
It is a very nice piece of software, which enables us to specify user interface in resource file, and change widget resources/hierarchy, etc. without recompiling the program. You may even be tempted to try it yourself, once you see how compact can a Motif program become, if you use WCL. Note that ArahPaint‘s WCL configuration file paint is smaller than UIL file of periodic (periodic a small Motif demo program)! WCL distribution also contains XmpTable Widget, which makes XmFrom and its wordy attachment specifications obsolete. The other libraries serve for TIFF, PNG, zlib, jpeg support. If you are running xpaint, xv or gimp, you probably have all these libraries and include files in place.

And last, but not least – ArahPaint is a Motif based program, so you need a Motif runtime and development system. If you run Linux or some other free operating system, you can download it from:

If you use a workstation from Sun, HP, Silicon Graphics or IBM, you probably already have the Motif included in your development system. ArahPaint uses very little Motif 2.1 functionality, so you can probably also compile it with Motif 1.2.x without a lot of work. It also compiles with LessTif, a GPL Motif replacement. Currently it still displays some geometry anomalies, if you use LessTif, but these will probably be resolved.


The description of changes is quite short, since it starts with the date of first public release of ArahPaint. Apart from the understandable embarrasement from past bugs – we do not want to disclose our development practice in details, including dates and specific customer requests. So here it goes:

September 2000: ArahPaint 2.8b


  • After clearing the selection, the move selection tool was still active. So program would allow you to move the selection, and then selection would disappear, or it would claim bogus Out of memory, if selection would overlap the image border. But, luckily, it would not crash.
  • File name in window title would be displayed only directly after loading a file, but if you rotated it or made a selection, it would not display it.
  • Improved feedback on color reduction. Now, if you click preview during color reduction, color palette window will also be mapped to reduced colors.
  • Visual inconsistence: After rotation of the whole image with line, unselect icon was inactive, instead of being active to signal the user that we now have a selection.
  • If you clicked fit to page in print setup, but did not click OK in repeat dimensions window, program printed image with wrong size, since it was not updated. Now, the size is updated automatically.
  • Program could crash if you used fill with color in repeat view on points out of the main repeat block.
  • Resolved a leak assign in handling of history filenames.
  • Resolved a non-fatal problem with accessing non-initialised memory in font selection code during initialisation.


  • Removed toolbar function draw dots, which was really useless, since all of its functionality was accessible by freehand draw.
  • Introduced function flip selection, indicated by diagonal arrows in the toolbar. This function rotates the image selection by 90 degrees. It works in the same way as such tool in ArahWeave. By pressing it twice you will get the initial position. If there is no selection, the whole image will be selected automatically. The toolbar icons have been slightly rearranged, so that rotate and flip icons are on the same height.
  • In set repeat size window, program now displays repeat size below zoom slider, which respects current zoom level. So you can easily adjust zoom level to arrive to desired repeat size in print.
  • Improved user interface consistency: all menu entries which do not perform the action directly, but pop-up a window, now contain dots (…) at the end of menu label.
  • Added automatic stitching of lancee fabrics for warp and for weft. The following explanation is for horizontal opeartion, it works in analogous way for vertical. It works similar as thinning, just that it removes points until only one point at the center stays. It also takes care so that it does not have stitch points on the same position vertically. The opearation is available from Tools->Contours->Stitch-> and then you have one icon for horizontal and one for vertical stitching.
  • Changed thicken contour operations so that they are automatically repeated the number of times equal to current setting of line width. Therefore if line width is 9, thicken contour is repeated 9 times. The other contour operations work as before, and are not affected by line width.
  • Change add contour function, so that it adds foreground color only around background color, not on all contours. If foreground color is equal to background color, then it adds contours on all borders of any two colors, as before.
  • Changed saving of history files, so that it is loaded/saved on every loading or saving of image. In this way, history files are up to date even if you are running several copies of arahpaint at the same time. Previously, the last copy of arahpaint would overwrite history file on exit, and it would read history file only on startup, so it would not know of any files which were loaded in arahpaints which were running in parallel.
  • Changed behavior of file selection box, so that it does not remember the directory if you were loading an image from a floppy. After loading the image from a floppy, it also constructs a new filename, with path of the current image directory and new image filename. So it is no longer necessary to climb back and forth between /home/capdam/data/img and /tmp/floppy
  • Changed default grid color from black to gray.
  • Added moving of selection around with cursor keys, nice for fine tuning. If selection has been cut out, then it moves around the selected area, otherwise just the selection rectangle is moved.
  • Removed function Delete file from Files menu. It was rarely used, and Linux has progressed to a point, where applications are always running with some kind of file manager. It is therefore unnecessary to provide file management tools in such application, or we would need to add creation of directory and renaming of files…
  • Added accelerator to reduce to selected area: r
    Added accelerator to guess weave from grid: g
    Added accelerator for saving: CTRL-S
  • Added an alternative interface to set transparent and protected colors. Open color window, click left mouse button to select color you want to change, and click middle mouse button to make color transparent, or right mouse button to make color protected. If the color is already protected/transparent, it will become unprotected/non-transparent. This way is much faster if you only need to change a color or two.
  • Added function Test repeat. If you have a selection, and you want to test if it makes a nice repeat or you might still need to adjust it, then enable this function in “Tools” menu. It will draw a block of 3×3 repeat around the currently selected block, so you see if it joins nicely. After 2 seconds it restores the normal image view. If you are not sure, just press it again, it has no effect on image contents. For now, it only simulates brick repeat. If this function will be well accepted by clients, we may add halfdrop and mirroring from setting of repeat parameters. It also has an accelerator: t
  • Added support for printing to Epson Stylus Photo 870/1270

February 2001: ArahPaint 2.8e

How to Compile It?

Once you untar and uncompress ArahPaint-2.8e.tar.gz, you will find the following directories in direcory ArahPaint-2.8e:
common/icons – icons
common/lib – extra libraries, which are not part of normal Linux distribution
common – common files with ArahWeave: dithering matrix
apaint/icons – more icons
apaint/msg – messages and help files with translations
apaint – program source
include/Xmp – XmpTable Widget include files
include/Wc – Widget Construction Library include files
llib – source for loading library
plib – source for printing and saving library

Compiling ArahPaint would be real easy, if we would not use any libraries. If you use Linux glibc system then you are lucky: libWc.so.2.7 and libXmp.so.2.7 are already compiled and in their proper place, that is common/lib
You will also need to copy the include files for WCL from include to
If you do not use Linux, or if you want to use this program with LessTif, you need to compile WCL-2.7, make these two shared libraries and copy them to directory common/lib.
WCL-2.7 is pretty old (from 1994), so you will not find Linux among the supported platforms ;-( If you find a quick and portable way to generate Makefiles we would like to know about that. But since WCL is really quality software, we only need to compile it when we switch platforms, or when Linux C library becomes backward incompatible in the name of the progress… You are pretty much on your own regarding compilation of WCL.

ArahPaint uses two other libraries – libAload.so and libAprint.so They were both developed by Arahne, so they will be easy to compile 😉 Just dive into both llib and plib, and type
This will build shared libraries, strip them and put them to proper location. The makefiles are handicrafted for Linux, but they are very simple, and do not use X11 or Motif, therefore adapting them to a different platform should not be a problem.

This leaves us with the simple task of compiling the core of ArahPaint source. Change your working directory to apaint and type
This will generate platform specific Makefile based on Imakefile. Check the Imakefile – it is really easy, and it is strange why so few people are using it? Maybe GNU folks also suffer from NIH syndrome? Now type:
M does not stand for murder, but is a small script which does make arahpaint, since many Imakefileconfigurations are broken in such way, that “make” will not know what to do. If you are real lucky, you can now type
apaint and enjoy ArahPaint, which you have compiled on your own! apaint is actually a small shell script, which sets the LD_LIBRARY_PATH environment variable (tells the shell where to look for libraries) and runs arahpaint executable. If you strip it, it should be less than 230 KB!

How can You Contribute?

As noted above, we do not bet our farm on the stempede of programmers who will rush from all around the world to write free code for us. We will be glad if you contribute a small bug fix, or if you find the program useful, only if it had this feature – and you do it… You can also send us corrections of translations.

Due to clean program arhitecture (at least in some parts), it is very easy to write a new image loader. So if you have tons of images in some weird format, and you want ArahPaint to read them, you can solve the problem. Of course, it was never our intention to write an image conversion program, and we are more interested in reading some files which are weaving specific, but we will not be picky.

If you really think you are capable and willing of doing something bigger, like things from TO-DO list, get in touch with us arahne@arahne.si so that we avoid any duplicate work. We might be even able to pay something for it, if you will not be offended. Of course, whatever you do will be released under GPL, and we will decide whether we want to include it in the next release or not.

For the time being, we will periodicaly distribute tarballs on our web site. We will just use the good old e-mail for communication, and upgrade to a more elaborate development/source distribution model, if/when the need arises.

TO-DO List

  • Multiple level undo, with in-memory compression of undo images
  • Unification of zoom code and main window display code
  • Zoom-out with drawing support (especially cut & paste of motifs)
  • Cut & paste of images between programs
  • Support for transparent colors on loading/saving motif
  • Support for scanning through SANE

Other Contributions

By looking through the program, you will be able to see that we have relied on parts of other open source programs, which we have then adapted to our needs. Sometimes, the adaptation was so big, that no line of code remained unchanged so there was no point of cluttering the code with large copyright notices. That code served only as a skeleton to make something useful for us. In other cases, were larger pieces of code could be used intact, we left those notices in the code. In any case, to do justice to everybody, here are our inspirations:

xpaint – we took some image loaders and adapted them to our architecture
Copyright (C) 1993, David Koblas
Copyright (C) 1995, 1996, 1997, 1998, Torsten Martinsen
Copyright (C) 1996, Greg Roelofs
Copyright (C) 1997, Scott D. Nelson
Permission to use, copy, modify, and distribute this software and its documentation for any purpose and without fee is hereby granted, provided that the above copyright notice appear in all copies and that both that copyright notice and this permission notice appear in supporting documentation. This software is provided as is without express or implied warranty.

nedit – for font selection
Copyright (c) 1992, 1993, 1994, 1996, 1997, 1998
Universities Research Association, Inc.
All rights reserved.

ArahPaint only links against these image libraries released under LGPL:

  • JPEG image format support ©1991-95 Thomas G. Lane, The Independent JPEG Group.
  • TIFF image format support ©1988-1997 Sam Leffler, ©1991-1997 Silicon Graphics, Inc.
  • PNG image format support ©1995-97 Guy Eric Schalnat, Group 42, Inc.

We also distribute unchanged WCL, so here is its license:
Copyright 1990, 1991, 1992, 1993, 1994 David E. Smyth
All Rights Reserved
Permission to use, copy, modify, and distribute this software and its documentation for any purpose and without fee is hereby granted, provided that the above copyright notice appear in all copies and that both that copyright notice and this permission notice appear in supporting documentation, and that the name of David E. Smyth not be used in advertising or publicity pertaining to distribution of the software without specific, written prior permission. This software is provided as is and without any warranty of any kind.


  • Gonzales, Woods: Digital Image Processing, for some morphological operators
  • Academic Press: Graphics Gems books, for various useful algorithms.


This program is released under GPL, not because we like it, but since this is what most people find acceptable. If you do not have it, fetch it from it here.
We reserve ourselves the right to change the license in future releases.
Arahne, d.o.o.
February 2001