ksherlock / iigs

Miscellaneous Apple II stuff that doesn't warrant a full project in and of itself

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

icon.py and icon resources clarification

xandark opened this issue · comments

I was just looking how to achieve what you have done with your icons in your .rez files and then I found your icon.py code.

It seems like it takes icons as raw files, is that right? If so, do you know how would one export the icon blobs in a resource fork to files?
iix rlist will list the resources, but that's not quite it.

Yes, it generates rIcon rez code for all the individual icons in an icon file. For gs gopher, the about window icon was given to me as an icon file so I wrote this to decompile it and then copy/pasted the output into the rez file.

If you want to generate a working icon file from a resource fork, I'm not sure if there's a direct way to do that. GS+ (The magazine) had an icon editor that could edit rIcons as well as normal icon files so you maybe that could be used to copy/paste an rIcon into a normal file. Reslin (see Richard Bennett's web page) is a GUI application that can view and export individual resources to a new file which might be what you want (but that just includes the icon bits, not all the other parts needed in an icon file). DeRez can also convert them into something that can be used with rez.

Okay, thanks, and which format is the icon file that you received? Which software created it, do you know? Maybe that would help so that I can verify that my file format is correct.

I remember DicEd, I think that's what it was called. I'll also check out Reslin.

Yes, I've used DeRez and it's given me an obtuse view of my icons and I'd like to move away from that to like what I see in your .rez file.

I just whipped up a little code to pretty-print rIcons -

https://github.com/ksherlock/iigs/blob/master/DeRezIcon.c

DeRez:

resource rIcon (0x1) {
	0x0,
	8,
	12,
	$"FF00 0000 0FFF FF0F FFF0 F0FF FF0F 00F0"
	$"00FF FF0F FFFF F0FF FF0F 0F00 F0FF FF0F"
	$"FFFF F0FF FF0F 0F0F F0FF FF00 0000 00FF",
	$"00FF FFFF F000 00FF FFFF FF00 00FF FFFF"
	$"FF00 00FF FFFF FF00 00FF FFFF FF00 00FF"
	$"FFFF FF00 00FF FFFF FF00 00FF FFFF FF00"
};

DeRezIcon:

resource rIcon(1, $0000) {
    $0000, // type (B/W)
    8, // height
    12, // width

    $"ff0000000fff"
    $"ff0ffff0f0ff"
    $"ff0f00f000ff"
    $"ff0ffffff0ff"
    $"ff0f0f00f0ff"
    $"ff0ffffff0ff"
    $"ff0f0f0ff0ff"
    $"ff00000000ff"
    ,
    $"00fffffff000"
    $"00ffffffff00"
    $"00ffffffff00"
    $"00ffffffff00"
    $"00ffffffff00"
    $"00ffffffff00"
    $"00ffffffff00"
    $"00ffffffff00"
}

Awesome! Thanks, I'll run it tonight.

Had to try it now, works great! 😊👏

This has worked out very well for me and I can actually tell what my icons are by the hex bytes. Could I convince you to extend your tool to do the same for rCursors? Or would you rather someone else extend it?

P.S. On line 97 of DeRezIcon.c, instead of

printf("}\n\n");

it needs to be

printf("};\n\n");

to be able to compile under rez

I was thinking about adding cursor support since they're so similar to icons. It has been added. However ... after playing around with the genesys cursor editor and derez I don't understand them. It looks like what should be one bit is really two consecutive bits? I'm sure it would display nicer if rez had bit strings instead as well as hex strings.

Great! And if it's any consolation, the output I received of my cursors from this new code looks great and I can easily tell which cursor is which by looking at the hex image map.

resource rCursor(1, $c018) {
    13, // height
    5, // width (20 bytes)

    $"00000000000000000000"
    $"0000000fc00000000000"
    $"000000fffc0000000000"
    $"00000fffffc000000000"
    $"000f000fc003c0000000"
    $"00ff000fc003fc000000"
    $"0fffffffffffffc00000"
    $"00ff000fc003fc000000"
    $"000f000fc003c0000000"
    $"00000fffffc000000000"
    $"000000fffc0000000000"
    $"0000000fc00000000000"
    $"00000000000000000000"
    ,
    $"0000000fc00000000000"
    $"000000fffc0000000000"
    $"00000fffffc000000000"
    $"0000fffffffc00000000"
    $"00fffffffffffc000000"
    $"0fffffffffffffc00000"
    $"fffffffffffffffc0000"
    $"0fffffffffffffc00000"
    $"00fffffffffffc000000"
    $"0000fffffffc00000000"
    $"00000fffffc000000000"
    $"000000fffc0000000000"
    $"0000000fc00000000000"
    ,
    6, // hotspot Y
    15, // hotspot X

    $80 // flags (640 mode)
};

That's a 4 way pointer, and my other cursors look just as good.