Maybe the following example is helpful.
Although the source (pixel_buffer_colored_radiation) has rectangular shape
its appearance on a target pixmap depends on its pixels' alpha values.
In this case one third of the pixmap is completely transparent white.
With the target pixmap set to 'copy mode' (target_pixmap.set_copy_mode)
- source pixmaps with pixel buffers and
- source pixel buffers
drawn onto the target look the same.
target_pixmap.set_copy_mode -- Should be the default.
target_pixmap.draw_sub_pixel_buffer (
100, 100,
pixel_buffer_colored_radiation,
pixel_buffer_colored_radiation.area
)
target_pixmap.draw_pixmap (
200, 200,
pixel_buffer_colored_radiation.to_pixmap
)
pixel_buffer_colored_radiation: EV_PIXEL_BUFFER
-- 100 x 100 pixel buffer with completely transparent parts.
--
-- Appearance:
--
-- OOOOOO
-- OOOOOOOOOOOOOOOO [r]ed
-- OOOOOO r OOOOO [g]reen
-- OOOOOOOOOO [b]lue
-- OOOOOOOO [a]lpha = 0 (full transparency)
-- a OOOOOO a
-- OO
-- OOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOO
-- OOOOOOOOOOOOOOO OOOOOOOOOOOOOOO
-- OOOOO g OOOOO OOOOO b OOOOO
-- OOOOOOOOOO a OOOOOOOOOO
-- OOOOOOO OOOOOOO
-- OOOO OOOO
-- O O
local
l_iterator: EV_PIXEL_BUFFER_ITERATOR
l_brightness: INTEGER
do
create Result.make_with_pixmap (pixmap_colored_radiation)
Result.lock
l_iterator := Result.pixel_iterator
from
l_iterator.start
until
l_iterator.after
loop
l_brightness := (
l_iterator.item.red.to_integer_32 +
l_iterator.item.green.to_integer_32 +
l_iterator.item.blue.to_integer_32
)
if l_brightness > 500 then
l_iterator.item.set_alpha (0)
-- Could be much more elaborated
-- with e.g. transparency gradients.
end
l_iterator.forth
end
Result.unlock
end
pixmap_colored_radiation: EV_PIXMAP
-- 100 x 100 radiation symbol with 3 different colors
-- on white background.
--
-- Note: `pixel_buffer_colored_radiation' is a companion
-- with total transparency instead of white.
--
--
-- OOOOOO [w]hite
-- OOOOOOOOOOOOOOOO [r]ed
-- OOOOOO r OOOOO [g]reen
-- OOOOOOOOOO [b]lue
-- OOOOOOOO [a]lpha (not used)
-- w OOOOOO w
-- OO
-- OOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOO
-- OOOOOOOOOOOOOOO OOOOOOOOOOOOOOO
-- OOOOO g OOOOO OOOOO b OOOOO
-- OOOOOOOOOO w OOOOOOOOOO
-- OOOOOOO OOOOOOO
-- OOOO OOOO
-- O O
local
pi: REAL_32
angle: REAL_32
do
create Result.make_with_size (100, 100)
-- Background is white by default.
pi := 3.1416
angle := -pi/3.0
across 1 |..| 3 as cur loop
angle := angle + pi/1.5
inspect
cur.item
when 1 then
Result.set_foreground_color (
create {EV_COLOR}.make_with_rgb (1.0, 0.0, 0.0)
)
when 2 then
Result.set_foreground_color (
create {EV_COLOR}.make_with_rgb (0.0, 1.0, 0.0)
)
when 3 then
Result.set_foreground_color (
create {EV_COLOR}.make_with_rgb (0.0, 0.0, 1.0)
)
end
Result.fill_pie_slice (0, 0, 100, 100, angle, pi/3.0)
end -- across
end
Best,
Karsten