Alvin wrote:

> matthiasm wrote:
> 
>> 
>> On 25.07.2008, at 15:23, Alvin wrote:
>> 
>>> According to the the FLTK manual, Fl_Image::color_average() states:
>>>  "The original image data is not altered by this method"
>>>
>>> This is great for what I am doing except I do not know how to have
>>> the image
>>> draw the "original image data". Basically, how can I remove the
>>> saturation?
>>>
>>> This applies to Fl_Image::desaturate(). It makes the same claim
>>> about not
>>> altering the original image data.
>> 
>> 
>> Both functions create a new image that you can use instead of the old
>> one, for example. You can then simply delete the old image if you like.
>> 
>> To draw an image, either cal someWidget->image(myImage), which will
>> make the image part of the label for that widget, or derive your own
>> widget and override the draw() function to draw you custom widgets
>> with your own ideas on where the images go.
>> 
>> Matthias
>> 
>> 
>> ----
>> http://robowerk.com/
> 
> Hmmm, I don't fully understand. I figured it created a new image, but the
> old one is stored in Fl_Image somewhere (perhaps data[1]?) The problem is
> the Fl_Image::color_average() doesn't have a return value.
> 
> Here's a trivial example:
> 
>    Fl_Button *b = new Button(......);  // Assume b is global
> 
>    Fl_Shared_Image *img = Fl_Shared_Image::get("/path/to/image.png");
> 
>    b->image(img);
> 
>    // now later in the code I want to darken the image
> 
>    b->image()->color_average(FL_BLACK, 0.4);
> 
>    // now even later I want to restore the original image
> 
>    b-> ????
> 
> As a work around, I store the original image in b's user_data(). I then
> make a copy of the image and call color_average() on the copy. I then set
> b's image() to the darkened, copied image. To restore the image, I move
> the pointer from user_data() to b->image() after I clean the darkened,
> copied image (delete it).
> 
> I figured that there would be a way to undo the color_average() and
> desaturate() since they do not modify the original image.
> 

Ugh, I (re)discovered Fl_Image::deimage(). For my purposes, this does
exactly what I'm trying to do. I simply store the darkened, copied image in
deimage(). Then when I deactivate the widget, that image is drawn. Then the
original is drawn when the widget is activated.

But still, the documentation implies (at least how I read it) that the
color_average() and desaturate() can be undone some how. Is this true?

-- 
Alvin
_______________________________________________
fltk mailing list
[email protected]
http://lists.easysw.com/mailman/listinfo/fltk

Reply via email to