Mailing List Archive: 49091 messages
  • Home
  • Script library
  • AltME Archive
  • Mailing list
  • Articles Index
  • Site search
 

Capturing transparent faces.

 [1/7] from: carl::cybercraft::co::nz at: 26-Jun-2005 0:07


Hi all, 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 view lo view layout [ backdrop green text "Image grab from layout..." image lo-grab text "Image grab from window..." image window-grab ] So, is there a way to do this on just a layout? Thanks in advance, -- Carl Read.

 [2/7] from: petr:krenzelok:trz:cz at: 25-Jun-2005 22:09


Carl Read wrote:
>Hi all, >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.
<<quoted lines omitted: 10>>
>] >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. But - even if you first apply view lo and then "lo-grab: to-image b", you apply 'unview after the button press. 'lo object still remains in memory, but who knows what 'unview causes internally. Better ask some guru ... -pekr-

 [3/7] from: volker:nitsch:g:mail at: 25-Jun-2005 23:47


On 6/25/05, Petr Krenzelok <[petr--krenzelok--trz--cz]> wrote:
> Carl Read wrote: > >Hi all,
<<quoted lines omitted: 22>>
> 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]
> But - even if you first apply > "view lo" and then "lo-grab: to-image b", you apply 'unview after the
<<quoted lines omitted: 23>>
> To unsubscribe from the list, just send an email to > lists at rebol.com with unsubscribe as the subject.
-- -Volker Any problem in computer science can be solved with another layer of indirection. But that usually will create another problem. David Wheeler

 [4/7] 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
<<quoted lines omitted: 47>>
>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.

 [5/7] from: volker:nitsch:gmai:l at: 26-Jun-2005 1:30


On 6/26/05, Carl Read <[carl--cybercraft--co--nz]> wrote:
> On Saturday, 25-June-2005 at 23:47:09 Volker Nitsch wrote, > >On 6/25/05, Petr Krenzelok <[petr--krenzelok--trz--cz]> wrote:
<<quoted lines omitted: 51>>
> >!>> 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.
Tried a bit, quite confusing. found two ways: 1) One was with 'view, grabbing the face itself does not work without it. 2) But what you can do is: lo-grab: copy/part at to-image lo 30x20 80x30 (note you have to get it from the whole layout, not just the box) Easier than those numbers to exact face-content: lo-grab: copy/part at to-image lo b/offset b/size
> 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] >
Ooops. hmm. Once long before something did not work! Must have been something different. Ok, thanks for the tip :)
> -- Carl Read. > > -- > To unsubscribe from the list, just send an email to > lists at rebol.com with unsubscribe as the subject. >
-- -Volker Any problem in computer science can be solved with another layer of indirection. But that usually will create another problem. David Wheeler

 [6/7] from: carl:cybercraft at: 26-Jun-2005 12:22


On Sunday, 26-June-2005 at 1:30:49 Volker Nitsch wrote,
>> >Pekr, if you continue at that pace, you will be guru shortly ;) >> >And the solution is:
<<quoted lines omitted: 31>>
>Easier than those numbers to exact face-content: > lo-grab: copy/part at to-image lo b/offset b/size
Ah - that did the trick! In View 1.3, anyway. (AT, and perhaps COPY, have obviously been improved to cope with the new View.) Thank you! -- Carl Read.

 [7/7] from: antonr:lexicon at: 27-Jun-2005 18:56


Hmm, you are right. This is going to need some more investigation and probably will go into Rambo. (I think I remember this problem from years ago...) A possible workaround *may* be to do it by setting b/saved-area to what the background should be. Or else you must view the window to render the effects: window: layout [ t: text "I am text underneath" effect [merge luma 20] at 10x10 b: box "hello" with [color: none] effect [merge gradmul 120.120.120 150.140.130] ] view/new/offset window -1000x-1000 ; necessary for win-offset? to work (uses parent-face) image: copy/part skip to-image window win-offset? b b/size unview/only window view layout [image (image)] Not entirely satisfactory, since a window is created and destroyed in a flicker. If you have many faces to do, then there is a flickering user interface. Perhaps to alleviate this an already open window can be used, though I suspect clipping will not allow faces with negative offsets to be rendered properly. Anton.

Notes
  • Quoted lines have been omitted from some messages.
    View the message alone to see the lines that have been omitted