Initial data commit
This commit is contained in:
parent
72d218235f
commit
f23f22d71c
199087 changed files with 3378941 additions and 0 deletions
25
Task/Bitmap/Erlang/bitmap.erl
Normal file
25
Task/Bitmap/Erlang/bitmap.erl
Normal file
|
|
@ -0,0 +1,25 @@
|
|||
-module(ros_bitmap).
|
||||
|
||||
-export([new/2, fill/2, set_pixel/3, get_pixel/2]).
|
||||
|
||||
-record(bitmap, {
|
||||
pixels = nil,
|
||||
shape = {0, 0}
|
||||
}).
|
||||
|
||||
new(Width, Height) ->
|
||||
#bitmap{pixels=array:new(Width * Height, {default, <<0:8, 0:8, 0:8>>}), shape={Width, Height}}.
|
||||
|
||||
fill(#bitmap{shape={Width, Height}}, {rgb, R, G, B}) ->
|
||||
#bitmap{
|
||||
pixels=array:new(Width * Height, {default, <<R:8, G:8, B:8>>}),
|
||||
shape={Width, Height}}.
|
||||
|
||||
set_pixel(#bitmap{pixels=Pixels, shape={Width, _Height}}=Bitmap, {at, X, Y}, {rgb, R, G, B}) ->
|
||||
Index = X + Y * Width,
|
||||
Bitmap#bitmap{pixels=array:set(Index, <<R:8, G:8, B:8>>, Pixels)}.
|
||||
|
||||
get_pixel(#bitmap{pixels=Pixels, shape={Width, _Height}}, {at, X, Y}) ->
|
||||
Index = X + Y * Width,
|
||||
<<R:8, G:8, B:8>> = array:get(Index, Pixels),
|
||||
{rgb, R, G, B}.
|
||||
Loading…
Add table
Add a link
Reference in a new issue