Mike Wallace Disk (Disk 98) (Jul 1988) : IconImage /

Options:

Name Size Date Type
../
IconImage 7240 1988-06-12
IconImage.c 2133 1988-06-12 Text [Original]
IconImage.doc 1330 1988-06-12 Text [Original]
iconimage.lnk 105 1988-06-12 Text [Original]
README.fnf 132 1988-06-12 Text [Original]

IconImage.c

#include <stdio.h>
#include <exec/types.h>
#include <workbench/workbench.h>
#include <workbench/icon.h>
#include <workbench/startup.h>
/***********************************************************
            iconimage.c
 This program will replace an old icon  image with a new
image without effecting icontype and drawer data etc.
eg A tool image can be used to change the image of a
disk icon.
       by Denis Green 18 Nov 1987
compile under Lattice 4.0 using lc -Lcd  iconimage
************************************************************/
int IconBase;

void main()
{
char name[20];
char newimage[20];
char *key;
	struct DiskObject *newdiskobj, *olddiskobj, *GetDiskObject();
key = "  ";
printf("CHANGE ICON IMAGE\n ");
printf("by GREENSOFT 1987\n\n ");

printf("Enter icon name to change\n ");
gets(name);
printf("Enter new image name\n ");
gets(newimage);
	if ( (IconBase = OpenLibrary( ICONNAME, 1)) == NULL)
		exit(2);

	/* read the icon to modify from disk */
	if ( (olddiskobj = GetDiskObject(name)) == NULL)
		{
		printf("Cannot read icon for %s\n", name);
		CloseLibrary( IconBase );
               printf("Press RETURN to exit. ");
               gets(key);
		exit(3);
		}

	/* read the second icon to get its image */
	if ( (newdiskobj= GetDiskObject(newimage)) == NULL)
		{
		printf("Cannot read icon for %s\n", name);
		FreeDiskObject(olddiskobj);
		CloseLibrary( IconBase );
                printf("Press RETURN to exit. ");
                gets(key);
		exit(4);
		}
	olddiskobj->do_Gadget.GadgetRender = newdiskobj->do_Gadget.GadgetRender;
        olddiskobj->do_Gadget.SelectRender = newdiskobj->do_Gadget.SelectRender;
	/* modify the flags so that it can use an alternate image */
 
	olddiskobj->do_Gadget.Flags = newdiskobj->do_Gadget.Flags;
        olddiskobj->do_Gadget.Width = newdiskobj->do_Gadget.Width;
        olddiskobj->do_Gadget.Height = newdiskobj->do_Gadget.Height;
	/* now write the modified  icon to disk */
	if (!PutDiskObject( name, olddiskobj))
		printf("Cannot write new icon - code %d\n", IoErr() );



	FreeDiskObject( olddiskobj );
	FreeDiskObject( newdiskobj);
	CloseLibrary( IconBase );

}

IconImage.doc

                                  IconImage
     This program will replace an old icon  image with a new
image without effecting icontype and drawer data etc.
     eg. A tool image can be used to change the image of a
disk icon.
     I have found it a useful tool in manipulating icon images without 
changing the other parameters in the diskobject structure. It is particularly
useful to play with some of the excellent icons that are on the PD disks. You
can also thoroughly confuse everyone if you decide to use a drawer or disk 
image for a tool or project.
     I decided not to use argv and argc in main() in order to allow the 
program to run from WorkBench. The standard workbench startup method does
not allow you to manipulate drawer,trashcan and disk images.
     The program can be used from workbench or the CLI.
It asks for two parameters, the first one being the name of the icon to be
changed and the second is the icon image to use in its place. Do not use the
".info" suffix in the names.
   Using this program it is easy to use a tool icon's image 
for a disk icon's image.

eg iconimage
  Enter icon name to be changed
  disk
  Enter new  image name
 df0:system/iconed

I am putting this program into the public domain.

  
Denis S. Green
 Greensoft
Running Creek Road
via RathDowney
Queensland
Australia 4287

iconimage.lnk

FROM LIB:c.o+iconimage.o
TO iconimage
LIB LIB:lc.lib+LIB:amiga.lib
SMALLCODE
SMALLDATA
MAP iconimage.map

README.fnf

This material was submitted to me on disk directly by the author,
Denis Green, for inclusion in the library.

-Fred  ><>
 22-Dec-87