------------------------------------------------------------------------------- Postscript to Images (anti-aliasing lines and fonts) If you just convert a postscript file to an image directly (using ghostscript), you will get it at 72dpi resolution with lots of "jaggies". A better idea is to do this at a larger resolution and then shrink it so that the lines, fonts and edges are properly anti-aliased... Example with convert, which performs the ghostscpt/resize together (A method of super-sampling) convert -density 288 foo.ps -resize 25% foo.jpg The -density option increases the number of pixels (or dots) generated by the ghostscript program when processing the input postscript file. However as all other images formats are generatly displayed on screens which are typically about 72 to 100 dots per inch, the output image will be larger. The -geometry will then reduce the large image output of ghostscript image back to a normal 72 dpi resolution (25% of 288 dpi gives 72 dpi) but in the process anti-alias (or smooth) the fonts and lines of the image so as to remove the "jaggies" you would otherwise get from a normal postscript to image conversion. Other posibilities which is good enough for the web and requires less memory -density 144 -geometry 50% factor 2 -density 108 -geometry 33.3% factor 3 WARNING: many lines in postscript remain one pixel wide lines, regardless of what scale you draw at. As such drawing a image at a large scale then shrinking can result in the lines becoming dimming and less distinct. Sumularly drawing a a small scale, can produce a very haevy bold outlines in the final image. ------------------------------------------------------------------------------- Image Arithmetic to mask out image. in PbmPlus I can use a mask to add a transparency with... # Mask out pixels in the original file pnminvert $MASK | pgmtoppm "#FFF" | pnmarith -multiply $IMAGE - > $TMP # set masked pixels as the transparent color "$TRANS" pnmdepth 255 $MASK 2>/dev/null | pgmtoppm "$TRANS" > $TMP2 # Merge mask color into cleared pixels of image pnmarith -add $TMP2 $TMP | ppmtoxpm 2>/dev/null | sed "/colors/,/pixels/s/c $TRANS/c None/" | # substitute trans xpm-fix -o "${name}_masked.xpm" ImageMagick has simular methods, but using a full aplha channel transparency. EG: semi-transparent posibilities. ------------------------------------------------------------------------------- Enlarging an Image nicely The standard way of doubling an image size is to just use each pixel twice in each row and column. For better results... Insert zero (black) pixel between the original pixel values, then blur the image (each pixel becomes the average of its neighbours). You may like to divide the result by 8 instead of 16 to stop the image being dimmed from the black pixels. For shrinking do the oppisite, blur the image first, then throw away every other pixel. Extract from Comp.Graphics FAQ, Q3.05 See also "anti-aliasing enlarged bitmaps" below. ------------------------------------------------------------------------------- anti-aliasing enlarged bitmaps. Example: enlarging a 20x20 bitmap for a 300dpi laser printer removing the jaggies. The only satisfying way to get bitmaps bigger without sacrificing quality is to turn them into vector-based graphics. Adobe Streamline or a similar program can autotrace the image and, then it can be cleaned up on a object oriented drawing package. rowley@jackatak.raider.net (Michael Rowland) There was some work done with bitmaps of Japanese characters where each square pixel was replaced with square, triangle, quarter-circle, etc. shapes and that outline rendered to produce a smoother shape at large sizes. The results were a little weird if magnified too much, but it's worth looking into. The files are somewhere in the neighborhood of [anonymous.tex.babel.japanese] on ymir.claremont.edu dhosek@hmcvax.claremont.edu (Don Hosek) As far as fonts go, though, autotracing generally puts out.. well, shit. I've tried it for Japanese and Chinese, and even scanning in high-resolution images, you still don't get something like Japanese or Chinese if you scale it at all. Text really doesn't scale linearly. rsrodger@wam.umd.edu Graphics Gems III gives a good algorithm for filtered image rescaling that will do the trick quite nicely. sdenman@wolf.cs.washington.edu (Stuart Denman) ------------------------------------------------------------------------------- Edge to vector processing The package morph, by Alan Peters at Vanderbilt (ftp to image.vanderbilt.edu and get morph.tar) seems to be the pretty complete. But a good library, designed originally to convert large scale bitmap fonts to outline vector fonts is... AutoTrace http://autotrace.sourceforge.net/ ------------------------------------------------------------------------------- Coloring a drippy like font. Find a bitmap font with the `drippy outline wanted. and from it generate two images. First Image (mask) * Make the font white in color and the background whatever color the final fonts background should be (For Example: Black). * make the white font transparent. (Giftrans?) This image is a mask for the final font so we retain the outline of the original font. And will set the background of the final font image. Second Image (colors) * Run the font though the `oil paint' to round off the sharp parts of the font (EG: the fonts `drips' or bloody runs) * move the font image 2 pixels up * color the font a dark color (For Example: Dark Green) and the background an extremely bright glowing color (Ex: near pure green) Now we simply mask the second image with the orignal font outline For example using ImageMagick... combine -compose over font_colors.gif font_mask.gif drippy_font.gif OTHER POSIBILITIES Highlighting Instead of moving the font colors up, move it down 2 pixels and right 1 pixel. Colors for mask background should also be a color between the highlight color and main font color. Highlighting may be better done using a embosing and then shading the resulting greys instead. ------------------------------------------------------------------------------- Map the Framebuffer to a Pointer unsigned char * FrameBuffer = (unsigned char *)0xA0000000; Then access with FrameBuffer[i]=value or whatever. -------------------------------------------------------------------------------