World: r3wp
[View] discuss view related issues
older newer | first last |
Rebolek 31-Oct-2006 [5931] | so will you RAMBO it? 1.3.3 is right behind the door... ;)))) |
Maxim 31-Oct-2006 [5932x3] | I'll try to find where its going wrong... |
just found it... its in the grow-facets VID func: pair! [append pairs val] integer! [append pairs val] string! [append texts val] tuple! [append colors val] block! [append/only blocks val] file! [append files val] url! [append files val] image! [append images val] char! [new/keycode: val] logic! [new/data: new/state: val] decimal! [new/data val] time! [new/rate: val] note how the decimal! type is not properly set! | |
I'll RAMBO it right away. | |
Rebolek 31-Oct-2006 [5935] | yes, nice :) |
Maxim 31-Oct-2006 [5936] | done. |
Brock 31-Oct-2006 [5937x2] | can anyone provide a very simplistic example of how you would set the background of a face to be transparent? I've tried using a view face and by defining the face in vid with no luck. I'd also like to be able to save the resultant face out to an image with the transparency maintained... is this also possible? |
here's the program I am using this in... | |
Henrik 31-Oct-2006 [5939] | set color to none for the face |
Brock 31-Oct-2006 [5940x2] | REBOL [ Title: "REBOL Logo Maker" Purpose: "Generate a Hilight image" Author: ["Carl Sassenrath" "Gabriele Santilli"] Version: 1.0.0 Rights: "REBOL logo is a registered trademark of REBOL Technologies, USA." ] debug?: false hilight-colour: 255.0.0 ;0.112.99 ;request-color character: uppercase request-text font-type: "font-sans-serif" xthin-chars: charset "I!J" thin-chars: charset "1234567890ABDEFPRSZ" normal-chars: charset"CGHKLNOTUVXY" wide-chars: charset "WMQ" xwide-chars: charset "" special-chars: charset "*" if font-type = "font-serif"[ ;get-char: func [character][ if find character xthin-chars [if debug? [print "xthin"] char-offset: 8x2 char-size: 14] if find character thin-chars [if debug? [print "thin"] char-offset: 7x2 char-size: 14] if find character normal-chars [if debug? [print "normal"] char-offset: 6x2 char-size: 14] if find character wide-chars [if debug? [print "wide"] char-offset: 5x2 char-size: 14] if find character xwide-chars [if debug? [print "xwide"] char-offset: 4x2 char-size: 14] if find character special-chars [if debug? [print "special"] char-offset: 5x-2 char-size: 28] ;] ] if font-type = "font-sans-serif"[ ;get-char: func [character][ if find character xthin-chars [if debug? [print "xthin"] char-offset: 9x2 char-size: 14] if find character thin-chars [if debug? [print "thin"] char-offset: 7x2 char-size: 14] if find character normal-chars [if debug? [print "normal"] char-offset: 6x2 char-size: 14] if find character wide-chars [if debug? [print "wide"] char-offset: 5x2 char-size: 14] if find character xwide-chars [if debug? [print "xwide"] char-offset: 4x2 char-size: 14] if find character special-chars [if debug? [print "special"] char-offset: 4x-2 char-size: 26] ;] ] font-style: make face/font [style: 'bold name: font-type size: char-size] hilights: [ transform 0 1 1 0x0 0x0 fill-pen snow pen snow circle 10x10 9 fill-pen black pen black circle 13x13 9 fill-pen hilight-colour ;0.112.99 pen hilight-colour ;serve dark green - 0.112.99 circle 11x11 9 fill-pen white pen white font font-style text 1 char-offset character ;] ;] ] insert-event-func func [face evt][ if evt/type = 'resize [ bx/size: out/size: evt/offset bx/size/y: out/size/y: evt/offset/x / 23 * 23 n: to-decimal bx/size/x / 23 ;t-x: to-decimal bx/size/x / 23 + 5 ;t-y: to-decimal bx/size/y / 23 - 2 ; probe highlights ;logo-shape ; halt hilights/3: n hilights/4: n loc: to-pair :t-x :t-y show out ] evt ] view/options center-face out: layout [ origin 0 bx: box 23x23 green effect [draw hilights effect [key: green]][ ;logo-shape][ ; file: request-file/only/save/file join %hilight- [character ".png"] if not file [exit] if not find file ".png" [append file ".png"] save/png file to-image bx ] ][resize] |
this was Carl & Gabrielle's Rebol logo maker that I am repurposing. | |
Henrik 31-Oct-2006 [5942] | >> view layout [backdrop effect [gradient 0x1 black white] y: box "test"] (escape) >> y/color == none |
Brock 31-Oct-2006 [5943x2] | thanks Henrik, however, I still don't see any transparency saved. |
view layout [ bx: box "test" [ file: request-file/only/save/file %sample.png if not file [exit] if not find file ".png" [append file ".png"] save/png file to-image bx ] ] | |
Pekr 31-Oct-2006 [5945x3] | don't you need to use effect merge? |
view layout [b1: box 100x100 red at b1/offset b2: box 50x50 green edge [size: 2x2 color: blue] effect [merge]] | |
uhm, sorry, that works too, while I thought it will not :-) view layout [b1: box 100x100 red at b1/offset b2: box 50x50 edge [size: 2x2 color: blue] with [color: none]] | |
Henrik 31-Oct-2006 [5948] | effect merge is only used when merging DRAW results with the background, AFAIK |
Pekr 31-Oct-2006 [5949x2] | not sure - there was some change between 2.1 and later View iirc, maybe merge was first needed, later it was not, or vice versa ... |
ah, now I get it - if there is some effect involved, simply setting color to none would not work, it is needed to add merge to effect block ... it is well described in view-system doc | |
Brock 1-Nov-2006 [5951x8] | hmm, still unable to save out the transparent png file to maintain the transparent part in the png file. I was able to produce an image with two coloured boxes and then one box was then made transparent, however when saving that image out, the background appears the default grey colour that is used when no colour is specified. |
I'm missing something key here... can the background colour be made transparent? | |
view lay: layout[ origin 0 backdrop 255.0.0 box green 30x30 at 15x15 box blue 30x30 effect[merge] ] save/png %sample.png to-image lay | |
presents an image with a red background, green box in upper left corner and the blue box is transparent in the lower right corner. Save result shows red background image with green box. | |
adding effect [merge] to the backdrop now makes the backdrop transparent, however the save result shows the background in the default grey now instead of red. | |
removing the backdrop line altogether doesn't change the saved result from the step above. | |
adding lay/color: none after the definition of the layout block changes the saved result to now have a black background with the green box appearing inside in the top left corner. | |
changing the backdrop line to be backdrop with [color: none] again saves out with the default grey background. | |
Rebolek 1-Nov-2006 [5959x2] | I;m not sure if PNG saver supports transparent color |
Hm, seems I had different oppinion two years ago :) http://www.rebol.org/cgi-bin/cgiwrap/rebol/ml-display-thread.r?m=rmlHSHC | |
Cyphre 1-Nov-2006 [5961] | >> i: logo.gif == make image! [100x24 #{ 252525141414141414141414141414141414141414141414141414141414 14141414141414141414141414141414141414141414... >> i/alpha: 128 == 128 >> save/png %test.png i >> |
Rebolek 1-Nov-2006 [5962] | Cyphre: This is is alpha channel, I think transparency means key color |
Cyphre 1-Nov-2006 [5963x4] | IMO 'key color' is only alpha = 255 isn't it? |
Maybe I don't know what exactly need? | |
what you exactly need | |
Ah, you mean the 'key color' in PNG format spec...then I think this cannot be controlled using the SAVE function IMO. | |
Henrik 1-Nov-2006 [5967] | rambo it? |
Rebolek 1-Nov-2006 [5968] | it's not a bug, you can say 'missing feature' :) |
Henrik 1-Nov-2006 [5969] | well, IMHO those also belong in RAMBO.. |
Rebolek 1-Nov-2006 [5970] | You need to manipulate tRNS chunk in PNG file. REBOL saves PNG files in color type 2 (true color) I think, so you must set tRNS chunk to RGB (2 bytes per color) value of color you want transparent. See http://www.faqs.org/rfcs/rfc2083.html |
Cyphre 1-Nov-2006 [5971] | yes, you would need the tRNS chunk for that feature. |
Brock 1-Nov-2006 [5972] | Out of my league, thanks for the responses. |
Rebolek 1-Nov-2006 [5973] | Brock: or you can make mask image and set the areas you want transparent to alpha 255 and REBOL saves aplpha chanel |
Brock 1-Nov-2006 [5974x2] | Rebolek, okay thanks, in theory I understand what needs to occure, but have no idea what this would look like in code. |
If you are interested in possibly creating a sample, I'd love to see it. | |
Anton 1-Nov-2006 [5976] | Check out help.gif, it has an alpha channel, which survives after saving and loading. print mold help.gif/alpha save/png %image.png help.gif view layout [image (load %image.png)] Now process the image, replacing a particular colour with transparent: img: copy help.gif colour: pick img 12x12 repeat i length? img [if colour = pick img i [poke img i 0.0.0.255]] view layout [box red at 10x10 image (img)] |
Maxim 1-Nov-2006 [5977] | but that alpha is only a one bit plane no? |
Anton 1-Nov-2006 [5978] | No, 8-bit alpha. Observe: img: copy help.gif colour: pick img 12x12 repeat i length? img [if colour = val: pick img i [val/4: mod i 256 poke img i val]] save/png %image.png img view layout [box 300x300 red at 20x20 image (load %image.png) (img/size * 8)] |
Maxim 1-Nov-2006 [5979x2] | that's really strange. its possible that converting from bmp to png, RT realised the need to save the potential green mask. so they probably store the image properly inside, but when creating one from scratch.. the channel is not. |
and this leads me to... how in hell this you stumble accross this? :-) | |
older newer | first last |