Short: NEW! 32bit PNG icons on your Amiga !!! (68K and MorphOS) Author: elena@elena-fractals.it (Elena - www.elena-fractals.it) Uploader: elena elena-fractals it (Elena - www elena-fractals it) Type: util/wb Version: 1.06 Replaces: util/wb/PowerIcons.lha Requires: AmigaOS 3.5/3.9, Hi/True Color Workbench Architecture: m68k-amigaos; ppc-morphos ALWAYS DOWNLOAD AN UP TO DATE VERSION OF POWERICONS AND OTHER SOFTWARE OF MINE AT: HISTORY ---------------------------- 1.06 (03 Jun 04) -Added NEGATIVE option for negative selection effect. -Fixed a memory trashing in ICTRL_New. -Sometimes, disk-type icons could be loaded with wrong type. Fixed. -Added support for disabled device icons (they were erroneously displayed in selected state): now they get a nice "halt" logo overimposed. -Fixed a crash when invoking DrawIconState() on a layerless RastPort using SCROLLSPEEDUP option. -Added a check for 8 bit bitmaps: in such case you can now see at least a box instead of no icon at all. -Upon some developers' request, I added a couple of "private" IconControl() tags to gain access to the icon 32 bit ARGB data. These tags are: ICONA_Dummy + 301 (ICONCTRLA_GetARGBImageData1) and ICONA_Dummy + 303 (ICONCTRLA_GetARGBImageData2) The passed ULONG * will be set to point to the corresponding ARGB buffer, for the normal and selected image (for PNG icons, the selected image is generated algorithmically) -General fixes and improvements. Now the draw routines should be even faster! -Removed a Seek() which could cause a little overhead when loading icons. -The example icons drawer has been rearranged and many new icons has been added. -Docs slightly revised 1.05r1 (17 Jan 04) -Just updated the package a bit (new example icons added and revised docs) No changes made to the executable which is still 1.05 1.05 (21 Nov 03) -Added BETTEROUTLINE option to improve text outline effect. -Added SCROLLSPEEDUP option to optimize Workbench icon scrolling (thanks to a Georg Steger's idea). -In the case no default base type icon is found in ENV:Sys (drawer, tool, project, etc.) no icon was returned. Fixed. -Removed a subtle bug in the 68K version causing weird system slowdowns and crashes (register A4 in GetIconRectangleNew() was erroneously trashed by the code generator). Thanks to Tony Aksnes for the patient beta testing. -Some new example icons added 1.04 (30 Oct 03) -"Virgin" icons associated with executable files were loaded as Projects rather than Tools. Fixed. -Fixed a very dangerous bug in PrepIcon() that could lead to serious crashes and system instability loading single-image color icons via GetDiskObject(New)(). -Added a workaround for a bug in the original IconControl() function which could lead to crashes in conjunction with some single-image icons. -Sometimes using TextMode=1 the icon text was not completely erased leaving a vertical line at the extreme left. Fixed. -Improved DrawIconStateNew(). Icon and text alignment should be more precise now. -PNG icons for drawers without proper drawer data were passed to WB as tool icons, thus the associated drawer could not be opened. Fixed. -The example PNG icons included couldn't be loaded into paint programs because they still had a wrong crc (most of them was created and snapshotted under the old PI 1.0). They're OK now. -I created and included PowerIconsLogo.jpg: now PI has its official logo :-) 1.03 (25 Oct 2003) -Loading very little PNG icons (16x16 or so) could cause decoding buffer overflow with consequent system crashes. Fixed. 1.02 (23 Oct 2003) -Default icons got wrong size with icon.library < 45.10. Fixed. -Improved Workbench dragging of PNG icons using a white rectangle. Please don't ask me to improve it further since it's only a drawback for WB. -Added SWAPTEXTCOLORS option -Using GHOST=100 no additional calculation will be computed for default icons, so people thinking that the ghosting effect slows down scrolling may try this (even if I don't believe that) -Fixed some dangerous alignment problems that could cause crashes under some circumstances and problems with Amidock. -Overall code improvement and optimizations. Scrolling might be a bit faster now. 1.01 (20 Oct 2003) -CRC for icon hunk is now computed when writing icons back. So now you can load no more "virgin" icons in ImageFX or other paint programs where they previously issued a "CRC error" requester. Please note that ImageFX PNG loader is broken, however: even if you choose "YES" to load alpha channel, it will be lost. WHAT'S POWERICONS ?? -------------------- In short: PowerIcons is a patch allowing you to use PNG icons (24 bit with or without alpha channel) on your Amiga in a totally transparent and OS-friendly way! Also, it performs transparency for default icons (ala Ghosty) and true color mapping of standard Amiga icons (they can now be displayed in full quality with their real colors and without palette-based remapping) LEGAL ----- PowerIcons if FREEWARE! Pretending to make money from a community who's trying to survive like Amiga community is simply SAD. PowerIcons is Copyright © 2004 Elena Novaretti Any commercial usage of this archive (whole or partially) is FORBIDDEN. PowerIcons may not be distributed without this accompanying README file. A BRIEF HISTORY --------------- Since years one of my greatest dreams was having 24 bit icons with alpha- channel transparency on my Workbench. Ambient, the official MorphOS desktop, firstly introduced PNG (24bit+alpha) icon support in the Amiga scenery. I'm actually an happy user and developer under MorphOS on my beloved Pegasos board, but sincerely cannot use Ambient yet since it lacks too many features compared with Opus Magellan, Workbench 3.9 or any other modern desktop. Also, Ambient handles PNG icons internally without using any standard icon.library API, so other programs cannot benefit of them! For now, the only very shiny thing of Ambient is just PNG icons support: so, how to lose them ?? In the past I wrote some patches to give Workbench icons a better look. First of them was Ghosty (Aminet), allowing transparency for default icons. Then I made an improved version called "Ghosty+", which I never released to the public since it was a bit experimental, but which also allowed standard Amiga color icons to be displayed with their own proper 256 colors (with no remapping, so with an apparently "near-true color" quality - except for the ugly border). And next came PowerIcons. It has been a really hard job but at the end it came out and it was really worth the trouble! REQUIREMENTS ------------ All you need is AmigaOS 3.5 or 3.9 running an Hi/True Color Workbench, no special library or extra file is required. Please note that 8 bit screenmodes are NOT supported for obvious reasons! A very fast CPU and GFX Board is STRONGLY recommended. To fully enjoy PowerIcons you're suggested to use DefIcons and RAWBInfo (even if not required): how to live without them ? ;-) Oh, you need some nice PNG icons too, of course! (However, I included some nice examples made by me in the ExampleIcons drawer) NOTE ABOUT SPEED ---------------- PowerIcons is intended for VERY fast and modern Amigas. Even if loading of PNG icons is done 80% by hand (i.e. without the overhead of libpng or -even worse!- datatypes system) this job will surely result in much more stress for the CPU than loading plain Amiga icons. Also, alpha-transparency blitting is done "by hand" since there's no API for hardware alpha acceleration at the moment (I wrote highly optimized routines but they cannot make miracles...) So the fastest CPU and the fastest GFX card you have will never be too much. Best performance is obtained using PowerIcons 68K under Amithlon/UAE JIT or PowerIcons PPC (with Amiga Workbench) under MorphOS. NOTE ABOUT MORPHOS VERSION -------------------------- A very fast PowerPC version of PowerIcons is included for exclusive usage under MorphOS. Actually, the only people who may benefit from this version are Workbench users under MorphOS emulation (typically MorphOS 0.4 for Amiga PowerUP). DON'T try to launch the included PPC version (PowerIcons.elf) if you don't have MorphOS: your system will crash. (See also the FAQ document) INSTALLATION ------------ Please remove ANY patches to icon.library, like my Ghosty (for example), otherwise serious conflicts may take place !!! Copy PowerIcons executable in C: or wherever you want. PowerIcons should be launched in your Startup-Sequence with RUN (it doesn't detach itself) JUST BEFORE LoadWB. A typical line would look like: ... Run >NIL: PowerIcons >NIL: [options] LoadWB EndCLI >NIL: On some slow machine *might* happen that desktop icons aren't patched by PowerIcons. It never happened AFAIK, but if it's the case, a "wait 1" between PowerIcons and LoadWB lines may help. Nothing prevents you from launching it by hand after Workbench has started, but by doing so you won't be able to use PNG icons on the desktop or in other applications (like AmiDock) started BEFORE PowerIcons! When you're sure you like PowerIcons and you plan to have it running definitely on your machine, go in Workbench Prefs editor and set IconQuality to BAD. Since color icons will be now drawn with true color remapping, doing so won't affect icon quality (except when dragging icons from Workbench but that's practically unnoticeable) and more pens will be available to your system. USAGE ----- PowerIcons needs no icon and is intended mainly for command line usage. If you launch PowerIcons with a '?' as argument, a brief list of supported options will be issued. PowerIcons supports the following options: GHOST=0...100 Transparency amount for default icons, i.e. for files without a "real" icon. A value of 100 means no transparency, 50 means 50% background and 50% icon, and 0 means you won't see anything. Using a value of 100 will spedup things a bit since no additional computation for the transparency effect will be done. Suggested values range from 40 to 60. (Defaults to 40) NOGHOSTSELECT Don't apply the transparency effect to default icons when they're selected. (Default is ghosting selected icons too) SWAPTEXTCOLORS Use icon text color for background/outline/shade and background icon text color for the text. (Default is off) BETTEROUTLINE With TEXTMODE=1 (outline) use eight instances of dark underlying text instead of only four, resulting in a more precise outline effect, mainly when using tiny fonts. Remember that this could slow down icon drawing and scrolling expecially on slow machines. (Default is off) SCROLLSPEEDUP Enable a special trick to speed up icon scrolling in Workbench windows, restricting refresh only to those icons which really need being updated. Thanks to a suggestion from Georg Steger. (Default is off) TEXTMODE=(0|1|2) Optionally, PowerIcons allows you to improve icon text rendering with shadow or outline effect. With 0, no effect will be applied and icon text will be rendered the same way your Workbench would do. With 1 you will get a nice outline effect and with 2 a shadow effect. The colors used for icon text and shadow/outline are those you set up in the Font prefs editor (but if you're using the SWAPTEXTCOLORS options they will be inverted, see above). (Defaults to 0) NEGATIVE Enable negative rendering effect for selected icons. If active, the following SELx options will be ignored. Note that the adopted PNG icon format doesn't support an alternate image, so the selection effect has to be obtained algorithmically. (Default is off) SELR=0...255 SELG=0...255 SELB=0...255 Red, Green and Blue values to add for PNG icons selection effect when NEGATIVE is NOT set. Note that the PNG icon format used doesn't support an alternate image, so the selection effect has to be obtained algorithmically. (Defaults to 96,96,144 which is a bluish lightening) For example: Run >NIL: PowerIcons NOGHOSTSELECT GHOST=50 SELR=80 SELG=80 SELB=80 TEXTMODE=1 REMOVING POWERICONS - WARNING! ------------------------------ To remove PowerIcons just launch it a second time. Removing PowerIcons while PNG icons are still loaded by Workbench or by other apps can be DANGEROUS! Please DON'T remove PowerIcons if you don't know what you're doing. LIVING WITH POWERICONS ---------------------- Firstly you should obtain some nice PNG icon pack to start enjoying (and testing!) PowerIcons. Here are a few sources you may have a look at: -Aminet (there are some PNG icon archives on Aminet in pix/icon) -www.kdelook.org (you will find a lot of PNG icon archives there) Once installed and launched correctly, PowerIcons adds transparent support for PNG icons to the standard icon.library API. This means that you will be able to fully handle PNG icons just as if they were standard Amiga icons. Any program and utility using the icon.library API to copy, clone, draw and delete icons will work flawlessly. Thus you will be able to use RAWBInfo (or even the old, ugly Workbench Information requester) to easily change icon images as usual, without dirtying your hands from a shell: you may drop a PNG icon over a standard Amiga icon, a PNG icon over another PNG icon or even a standard Amiga icon over a PNG one in RAWBInfo to change your icon image! If you (as suggested) are using DefIcons, you will enjoy using PNG icons as default icons in ENVARC:Sys. PNG AppIcons will work as well, and you can also drag your PNG icons into programs like AmiDock... In general, the only programs that won't work or that will work badly (or, even, that might cause crashes with PowerIcons) are very old or very badly written ones, which don't use the icon.library API to handle icons but rather do too many things "by hand"... HOW TO CREATE CUSTOM PNG ICONS OR PNG ICONS FROM PNG PICTURES ? --------------------------------------------------------------- Simply rename your PNG image from Foo.png to Foo.info: your Workbench will be ready to display and handle it as a normal icon! If you plan to draw your own PNG icons remember that creating good-looking pictures with alpha channel is not really a child's play... You need some practice, patience and some artistic talent. ImageFX requires you know exactly what you're doing but is a good start point. (See also the readme in the example icons drawer for some trick to create PNG icons with Amiga) ABOUT PNG ICON FORMAT --------------------- I don't know whether any standard has been set up or not for PNG icons over the major platforms. The format I choose is the one adopted by Ambient, so here I will mainly refer to it. PNG is a modern image file format supporting an often very high, lossless compression and optional alpha-channel for gradual transparency. PNG, just like IFF, supports different Hunks to store additional information like (in our case) an "icon" Hunk containing icon data (eg. drawer position, tooltypes, stack size, default tool, etc.) PNG icons are nothing else than normal PNG pictures whose name ends up with ".info", with (or without, when just created) a special "icon" Hunk to keep the proper icon information. If you're not familiar with alpha channel, it's simply an additional byte for every pixel specifying to what extent the image will be mixed with background. Typically, like in the case of the supported PNG format, images will use 32 bits per pixel: 1 byte for each red, green and blue as usual plus an additional byte for transparency (the alpha channel value). A pixel containing an alpha value of zero will look as the corresponding background pixel (0% picture, 100% bg). A pixel with an alpha value of 128 will be displayed as (about) the average of that pixel and the corresponding background pixel (50% picture, 50% bg), while an alpha value of 255 will show exactly the corresponding pixel with no background (100% picture, 0% bg). As you can see, alpha channel offers more complex transparency capabilities than the ugly-looking 0/1 masking we are used to, for example, with standard Amiga icons. Antialiased borders, lighting effects as well as shadows are now possibile with a properly drawn 32-bit image. PNG icons have NO intrinsic type, i.e. there's no field defined to establish whether an icon is of type Drawer rather than Tool or Disk... The new icon.library engine added by PowerIcons automatically adapts the loaded (or default) icon to the corresponding file, setting the correct type on the fly so that Workbench may properly understand and use it. The only identifying rule is represented by the fields containing Drawer Data or DefaultTool. If an icon contains a DefaultTool, it will be early identified as a project (if that causes no inconsistency). If an icon contains some DrawerData, it will (possibly) be suitable as a drawer or disk icon. At PNG level, you can then have "virgin" icons, i.e. PNG images not containing any "icon" hunk yet (mainly, this happens when an icon has just been created from a paint program and/or hasn't been snapshotted or modified yet) but you won't absolutely need to care about it. When you first snapshot an icon, or create its Tooltypes, DefaultTool, StackSize and/or other icon information, an "icon" hunk is automatically created to hold the needed information in the PNG icon file. USING POWERICONS AS A DEVELOPER ------------------------------- Upon some developer's request, I added a couple of IconControl() tags: #define ICONCTRLA_GetARGBImageData1 (ICONA_Dummy+301) #define ICONCTRLA_GetARGBImageData2 (ICONA_Dummy+303) You may use them in your code to get direct access to the icon ARGB 32-bits image buffer. An ULONG * passed as ti_Data will be filled in with the proper address. The buffers are obviously valid until you dispose of the relative icon. For PNG icons, the selected image buffer (data2) will be generated on the fly basing on the user selected PowerIcons options, since PNG icons have actually no second image. You may get ARGB data from normal Amiga Color icons aswell, to get the full (not remapped) 24 bit imagery and the alpha channel being 0 or 255, depending on the original transparency mask. You need PowerIcons 1.06 to use these new tags. Please always check IconControl() return code. KNOWN LIMITATIONS ----------------- No. NO. NOOO!!!!! PowerIcons DOESN'T WORK WITH MAGELLAN !!!!!!!!!! These desktops do every icon operation by hand without using the icon.library API so there's definitely NO WAY! Don't ask it anymore ! Since Workbench uses internal planar routines for icon dragging, it wasn't possible to have it dragging true color imagery. A simple four-color image representing a white box with a PNG text has been provided just to have Workbench displaying something when dragging PNG icons. Unfortunately there's definitely NO OTHER SOLUTION. Please DON'T ask to improve it. For obvious reasons you won't be able to use standard icon editors on PNG icons. Please don't, since you may obtain unpredictable results, and really there's no need. Compatibility with other system or icon.library patches CANNOT BE GUARANTEED! Compatibility with utilities to inject or change icon imagery is absolutely not guaranteed (99% of them won't work or will destroy any previously stored PNG imagery). Ghosting of icon text (like in Ghosty indeed) is not implemented yet, by choice, in order to reduce the overhead, and for many other technical reasons. Old-style amiga icons (planar icons) are simply NOT patched by choice. No true-color remapping or ghost effect is applied in the case such an ugly old icon is encountered and it will be passed to the original DrawIconState() as it is. Icon border is NOT supported by choice. For speed reasons, not all PNG image formats are supported. Please use only True Color pictures with or without alpha channel (24 or 32 bits). Grayscale, palette mapped, interlaced, not-alpha transparency pictures and many other exotic formats are NOT supported. A FINAL NOTE... -------------------- You will probably start loving and using PowerIcons from the beginning. So you'll spend hours and hours drawing 32 bit icons or customizing your programs with shiny icons downloaded from somewhere. But remember: at that point there's NO WAY TO SWITCH BACK! If you (for any reason) should remove PowerIcons you WON'T BE ABLE TO SEE YOUR ICONS AND YOUR TOOLTYPES ANYMORE! What does that mean ? Nothing particular, that's quite obvious indeed. You're just warned :) ****************************************************************************** ! ENJOY AND LOVE POWERICONS ! ! PLEASE SEND ME ANY BUG OR SUGGESTION ! ****************************************************************************** AUTHOR: Elena Novaretti www.elena-fractals.it PowerIcons has been developed on a Pegasos(tm) and compiled with the great VBCC.