#include #include #include #include #include /*********************************************************** 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 ); }