[REBOL] Re: Capturing transparent faces.
From: carl:cybercraft at: 26-Jun-2005 10:24
On Saturday, 25-June-2005 at 23:47:09 Volker Nitsch wrote,
>On 6/25/05, Petr Krenzelok <[petr--krenzelok--trz--cz]> wrote:
>> >If you have a transparent face in View, it can be used to grab an image
>> >of the faces under it. However, I can only get this to work on a layout in
>> >an open window - when I attempt it on layout, all I get is a black image.
>> >
>> >Here's an example of this: Just run it, click on the "Grab Area" button
> and you'll see what I mean...
>> >
>> >
>> >rebol []
>> >lo: layout [
>> > title "Grab area test."
>> > at 30x20
>> > b: box 80x30 with [color: none] ; Transparent box.
>> > button "Grab Area" [
>> > window-grab: to-image b
>> > unview/all
>> > ]
>> >]
>> >lo-grab: to-image b
>> >
>> >
>>
>> Look, I am no guru at View, but imo following happens. Feel free to
>> correct me eventually:
>>
>> you create snapshot of 'b (lo-grab), even before it is being shown for
>> the first time. Imo layout just defines structures, but does not apply
>> effect, until the face is actually shown.
>
>Pekr, if you continue at that pace, you will be guru shortly ;)
>And the solution is:
>You can show things without viewing them.
>That forces /view to paint into the internal buffers.
>A to-image just dumps these buffers, without a 'show there is just black.
>So
>
>!>> lo: layout [
>[ title "Grab area test."
>[ at 30x20
>[ b: box 80x30 with [color: none] ; Transparent box.
>[ button "Grab Area" [
>[ window-grab: to-image b
>[ unview/all
>[ ]
>[ ]
>!>> show lo
>; ^^^^^^^^!!!!!!!!!
>!>> lo-grab: to-image lo
>== make image! [220x102 #{
>C8C8C8C8C8C8C8C8C8C8C8C8C8C8C8C8C8C8C8C8C8C8C8C8C8C8C8C8C8C8
>C8C8C8C8C8C8C8C8C8C8C8C8C8C8C8C8C8C8C8C8C8C...
>!>> view layout[image lo-grab]
Thanks Volker (and Petr), but that still doesn't do what I want, which is to capture
'b, not 'lo.
And incidentally, you don't need to SHOW a layout before capturing it - this works just
fine...
pic: to-image layout [text "Some text." button "A button"]
view layout [image pic]
-- Carl Read.