World: r3wp
[View] discuss view related issues
older newer | first last |
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? :-) | |
Anton 1-Nov-2006 [5981] | The image! datatype has an optional alpha channel. If it does not exist, it will be created when you set a pixel with alpha. |
Maxim 1-Nov-2006 [5982] | ok, I read back a bit and I understand more the origin of the discussion. I had assumed brock had an image with an alpha and was not able to save it out. his real question basically... how do I CREATE the alpha channel from View gfx. and you have answered that. sorry for stickin my head in my ass, I should have read above. |
Louis 1-Nov-2006 [5983] | Is there any way to disable the exit button in the upper right corner of a window (the button with the X in it) or else reprogram it to exit according to my own rebol code? |
Maxim 1-Nov-2006 [5984] | the window's feel is different and accepts 'close events (in feel/detect). it not very easy to deal with this because when you call 'view on a window, its feel is replaced automatically by view. so you must explicitely replace the feel AFTER calling view on a layout or a face. alternatively, you can also use an input even handler, which is probably a better solution: this is one way to handle the close for all windows: http://www.rebol.com/docs/view-system.html#section-5.13 |
Brock 2-Nov-2006 [5985x3] | Anton, great example... I was able to get this to work with a sample image that I created. Thanks so much. |
damn anti-aliasing!! now I have fringing or a halo effect around my image due to anti-aliasing. I'll see what I can do about this. Thanks again. | |
(I'm trying to create custom rounded bullets) | |
Maxim 2-Nov-2006 [5988] | ajusting gamma in the draw block may help, some artifacts may depend specifically on the colour being layered... |
Brock 2-Nov-2006 [5989x2] | My example uses some very contrasting colours. I'm guessing from your statement that you are suggesting making the original image background less contrasting and the effect will be minimized. |
I'll also play with eh gamma as you suggested as well. | |
Maxim 2-Nov-2006 [5991x2] | bad colors to mix are green and pink, for example. the effects are usually worse when they are side by side and edges overlap. |
a good trick is to set the gamma to one end, do the drawing and then compensate gamma back with its complement, to get original colors back. | |
Brock 2-Nov-2006 [5993] | yes, I had a green background, changing to a dark grey (near black) works nicely for my purpose, atleast on a larger image. |
Maxim 2-Nov-2006 [5994x4] | this is an old trick to fix the flickering stars effect you get when you try to move around small dots of white on a screen which has aliasing. |
(and bg is black) | |
but there are many possible edge artifacts... and its hard to say, what will be the best solution without looking at it directly. | |
(plus I'm not an AGG expert specifically) | |
Brock 2-Nov-2006 [5998x3] | I'm not using AGG in this instance. |
I found that the dark grey 'border' worked okay with a dark background and not so as suitable for a light background, atleast for the smaller image. | |
I'll play a little more before trying your gamma trick. | |
Maxim 2-Nov-2006 [6001x6] | dark haloes are sometimes due to the contrast of actual pixels when two colors are placed side-by side. |
consider this to be 2 pixels [b g r] [b g r] | |
if you had these two colors side by side (- meening that pixel channel is not lit): [b - - ] [- - r] | |
then I guess you can understand that our eye will notice that large 4 channel gap in between pixels. | |
the ordering of channels also means that these side-effects only occur in one direction: if you placed [ - - r] [b - - ] there would be no edge between red and blue (but will be from blue to next pixel) | |
MS's new font aliasing engine uses this technique to use sub channels so that edges actually hit pixel channels instead of complete pixels... whic is why some letters look colored on edges... but when you see it, there is very nice increase in overall quality... its like increasing the resolution of your screen by a factor of 3 ! | |
Louis 2-Nov-2006 [6007] | Maxim, thanks. I'll study that doc. |
Gabriele 2-Nov-2006 [6008] | brock, why don't you just use an alpha channel? |
Brock 2-Nov-2006 [6009x2] | I was able to get Anton's example to work in the scenario I had indicated above. I'm open to looking into your suggestion, do you have an example that I can use. I checked some of the rebol/view docs and the image datatype doc and don't see anything that guides me in the direction you are suggesting. |
By the way Anton, thanks for your example, works well except for the fringing around the ani-aliased part of the image... still maintains some of the colour of the original background colour. | |
Gabriele 2-Nov-2006 [6011x3] | if i understand correctly, you need to use draw to produce a transparent image. is that correct? |
so my question is, why do you need to make one color transparent, instead of using the alpha channel? | |
img: make image! 50x50 img/alpha: 255 ; make bg transparent draw img [pen black line-width 2 circle 25x25 20] save/png %test.png img | |
Maxim 2-Nov-2006 [6014] | he is not using draw. AFAIK |
Brock 2-Nov-2006 [6015] | Maxim, yes, I'm using draw. |
Maxim 2-Nov-2006 [6016] | doh... sorry. |
Brock 2-Nov-2006 [6017] | I'm creating the image in a block, then using draw to display the final image. |
Maxim 2-Nov-2006 [6018x3] | can you give us a real equivalent example? |
there are many possible edge defects... seeing them will help us cure the booboo :-) | |
right now we're like swatting flies in the dark... with you having the infra red goggles and saying: LEFT ! LEFT! .. oh no RIGHT! RIGHT ;-) | |
Brock 2-Nov-2006 [6021x5] | hilight-colour: 255.0.0 ;0.112.99 ;request-color font-style: make face/font [style: 'bold name: "font-sans-serif" size: 26] hilights: [ transform 0 1 1 0x0 0x0 fill-pen snow pen snow ;white circle circle 10x10 9 fill-pen black pen black ;black circle circle 13x13 9 fill-pen hilight-colour ;0.112.99 pen hilight-colour ;serve dark green - 0.112.99 circle 11x11 9 fill-pen snow pen snow font font-style text 1 6x0 "*" ] view center-face out: layout [ origin 0 bx: box 23x23 50.50.50 effect [draw hilights effect []][ file: request-file/only/save/file %hilight.png if not file [exit] if not find file ".png" [append file ".png"] save/png file to-image bx img: load file colour: pick img 1x1 repeat i length? img [if colour = pick img i [poke img i 0.0.0.255]] save/png file img ] ] |
this is a stripped down version (this time one that works without error) | |
clicking on the image brings up the save requestor | |
Using Gabriel's method creates a clean image without the fringing.... | |
hilight-colour: 255.0.0 ;0.112.99 ;request-color font-style: make face/font [style: 'bold name: "font-sans-serif" size: 26] img: make image! 23x23 img/alpha: 255 ;make bg transparent draw img [ transform 0 1 1 0x0 0x0 fill-pen snow pen snow ;white circle circle 10x10 9 fill-pen black pen black ;black circle circle 13x13 9 fill-pen hilight-colour ;0.112.99 pen hilight-colour ;serve dark green - 0.112.99 circle 11x11 9 fill-pen snow pen snow font font-style text 1 6x0 "*" ] file: request-file/only/save/file %hilight.png if not file [exit] if not find file ".png" [append file ".png"] save/png file img | |
older newer | first last |