My current project to make sure Enlightenment 0.17 is a hip and happening thing, is to make sure Imlib 2 gets written and works and does everything it needs to and I want it to.
So where does it stand right now? Well I'll take it one step at a time... first it has an abstracted loader system. It will automatically, runtime, pick up new loaders in /usr/local/lib/loaders/image (or wherever the prefix of the system loader dir is) and in $HOME/.loaders/image. It's as simple as dropping a loder (png.so, jpeg.so etc.) in those directories and bingo. Imlib will discover them and use them - query them as to what formats they can do (the name of the loader is irrelevant) and so on. It means Imlib2 can load and save images in whatever formats you have loaders for - add more formats by downloading and dropping in more loaders.. and it takes effect runtime - no restarting of apps or recompiling of libraries or editing of config files... This is the way things should be.
The loader mechanism supoprts progress callback functions, multi-phase loads (load header information first phase to glean format, size etc. information, load a second time to actually decode the image data). Writing a loader is child's play. Sofar I've only written jpeg and png loaders, but more will come - they are my testbed for now. A gif loader-only loader was contributed, a tga, bmp, tiff and xpm exit too and I have argb, ppm, pgm and pbm loaders too.
When an image is loaded - it's the loaders job to decode the image (and call progress callbacks in the application specifies a callback function) and convert the image data it's loading into ARGB format (32bits for each pixel) and fill in the Imlib_Image structure. Imlib 2 works completely in ARGB space. This provides speed of access since all pixles are 32-bit aligned in memory, and it provides an alpha channel.
This of course means Imlib 2 can alpha blend. It can actually do it quite fast. Infact here's a screenshot - it's showing a lot of advanced stuff that hasn't been covered yet - but it is showing Alpha blending of shadow parts on the top and left sides of the image. It's showing lots of little icons from GNOME alpha blended on an image in the background. It's also showing the gradient drawing function that can draw arbitary color ranges FAST - and yes - it can alpha blend too. Infact all of Imlib 2's operations can alpha blend.
Imlib 2 is also VERY fast at converting ARGB to screen depth. It handles 1 - 8 bit, 15 bit, 16bit, 24 and 32 bit color. It can dither 16bit color and under. In 8 bit and below it uses colorcubes of various sizes (332, 232, 222, 221, 121, 111, and monochrome) to allocate color and render. All allocation is done on-demand. It makes use of Mit-Shm if avaliable, and is pretty fast. My tests how it to be marginalyl faster than GdkRGB written by Raph Levien. It apparently works fine on PPC and Sparc machines too. It uses XImage caching to reduce the need to keep recreating Ximages. It can generate and cache pixmaps too - just like Imlib 1.x - but Imlib 2 is MUCH smarter and better at the job. Not to mention it's considerably faster.
In addition to being able to alpha-blend images ontop of eachother - and also perfrom Additve, Subtractive and Reshade operations whilst doing so, draw rectangles with arbitary color ranges as gradients in arbitary rotations, it can also draw text - anti-aliased, truetype fonts with any level of transparency and any color. Look here. That's a truetype font, loaded by imlib2, drawing in several levels of transparency and anti-aliased too. Imlib 2 can also draw the text in rotated forms (left to right, right to left, top to bottom and bottom to top). You can query Imlib 2 for font metrics of strings and characters, making it easy to impliment a widget set ontop of it. And just like any smart system it caches fonts and shares them between multiple references.
Imlib 2 also supports Color Modifier curves. You can pass any operation through a color modifier table that can correct gamma, brightness and contrast values of an image - as well as indepednantly being able to determine the mapping tables of each R, G, B and A channel in an image.
Imlib 2 can also draw anti-aliased lines too, as well as solid rectangles and boxes. In the future it will do anti-aliased polygons too I imagine as well as being able to do do arbitary rotation of images. You can blit regions of images too. Imlib 2 can also grab bits of your screen, pre or post scale them for screenshots or image porcessing, and work on them in ARGB color space. It can also concatinate overlapping and intersecting update rectangles togeteher into a more optimised set of rectangles to maximise efficency when redrawing parts of an image.
Imlib2 also can do smooth scaling of images - both up and down. This means when you expand an image beyond its original resolution, instead of it getting `blocky'' it gets fuzzy instead. The same for scaling an image down in size - Imlib will blend pixels together when scaling down (if you chose to use the option) so that you end up with smoother miniatures of the original image. Also just like Imlib 1.x it supports border scaling attributes to enable images to be scaled differently at the edges compared to the middle - allowing easy generation of buttons and other such beveled and bordered iamegs from single sized images.
Also just like Imlib 1.x, Imlib 2 does caching of image loading - allowing the programmer to forget if his or her code is efficient and let the library pick up the pieces after them. It will share images if loaded multiple times, and keep a speculative cache around just incase you load the image again. The cache sizes can be manipulated by the API easily.
You can also create images from your own data sets and thus use Imlib 2 as a raw rendering and processing engine. This makes it perfect for those that don't want to worry about what color depth their program is in - but still get maximum quality of results and have it display quickly.
Also some primitive image processing functions are provided that can blur and sharpen image data, as well as make image data tile seamlessly horizontally, vertically or in both directions (infact the code in Imlib 2 should produce much better tiled images than GIMP does since it uses a different algorithm). It can also flip images horizontally and vertically as well as diagonally. It can rotate images ANd even draw text at arbitary angles. I now also has a plug-in filter system like the loader/saver system for doing effects, it can do arvitary convolutions
So the code is getting bigger - and more powerful. currently Imlib 2 is about 26,000 lines of code. If you have any comments please mail me at firstname.lastname@example.org. I want to make sure I get this API right before it ends up being set in stone. I can always add calls, but once these calls are set in stone I can't change their names or their parameters or what they do. I really need help with multi-byte international font support since I personally only speak languages that are Latin-1 based and thus fit nicely in 1 byte per character, and are drawn from left to right. All input to do with other languages is very welcome - as are patches etc.
Imlib 2 also has optmized MMX assembly routines for blending, scaling and rendering if you have an x86 machine with MMX these routines speed things up anywhere from 40% up to 4-5 times the speed.
You can get the source by doing the following the instructions here and then checking out the imlib2 source tree (the imlib2 cvs module).
Imlib2 is now an actually library so you can use it in oyur own code - link to it and use it's API that you'll see in Imlib2.h The function call names should be pretty self-explanatory. I need to write soem more useful docs - I'll get to that.
If you cannot use CVS I make tarball snapshots of Imlib 2 every now and again. you can download one here:
Here is a list of links to people and projects using Imlib 2 that I know of
Proudly sponsored by:|