Re: saving ICOs



On Sun, 2003-06-29 at 10:41, Matthias Clasen wrote:
> So, in order to make gdk_cursor_new_from_pixbuf() implementable on
> Win32, I'm currently writing code to save ICOs. 

I don't believe this is the right approach on Windows. I did some
looking at this the other day and what you want to do is use
CreateIconIndirect(). The usage is far from obvious, but there
are some detailed instructions at:

 http://www.dotnet247.com/247reference/msgs/13/66301.aspx
 
for the WinXP case of alpha pixmaps. The same general approach is
probably right for older versions that only support colored icons,
though I'm sure the checks to figure out what to use where will
be messy.

> The problem I'm facing
> is that I don't think it will be enough to save only a single image; I
> think we will have to create an ICO (or CUR, rather) containing multiple
> versions at different sizes and bitdepths, to let the Win32 cursor code
> pick the preferred size/depth combination.What I have been working on so
> far is to do the scaling/depth reduction internally, so that one can
> write:
> 
>  gdk_pixbuf_save (pixbuf, "my.ico", "ico", &error, 
>                   "size", "16x16x16",
>                   "size", "32x32x16",
>                   "size", "64x64x32",
> 		  NULL);
> 
> or
> 
> gdk_pixbuf_save (pixbuf, "my.cur", "ico", &error,
>                  "x_hot", "8",
>                  "y_hot", "10",
>                  "size", "32x32x16",
>                  "size", "48x48x24",
>                  NULL);
> 
> to produce an ICO containing 3 bitmaps of size 16x16 with 16bpp, 32x32
> with 16bpp and 64x64 with 32bpp. The issues with this approach are
> 
> a) In order to support depths <= 8 I need to produce a colormap. Would a
> function like gdk_pixbuf_quantisize() be generally useful ? 
> 
> b) Doing scaling and quantization internally will probably produce
> suboptimal results. It would be nice if multiple pixbufs could be
> directly provided to the save function, but the only way to achieve that
> would be via hacks like g_object_set_data () on the pixbuf or providing
> the additional pixbufs as options via pointer->string.
> 
> I guess the questions I'd like to hear some opinions on are:

I guess my opinion would be to avoid such hacks unless we absolutely 
positively need them. If we do want to support multiple-size saving,
I suspect that adding a specific API for it would be better.

> 1) Do we need the ability to save multiple images in an ico to provide
> an adaequate implementation of gdk_cursor_new_from_pixbuf() on Win32 

I don't think so.

> 2) Is internal scaling/quantization acceptable or do we need to
> find a way to save multiple pixbufs into one file ?

Let's avoid answering this question until we have to.

> 3) Would gdk_pixbuf_quantisize() be generally useful ? 

Perhaps, but let's wait until we have an actual use case.

Regards,
					Owen





[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]