Skip to content

Commit 2f03044

Browse files
author
alishdipani
committed
Added offset and support for Numo::Narray
1 parent 5bae0ec commit 2f03044

File tree

1 file changed

+2
-3
lines changed

1 file changed

+2
-3
lines changed

lib/rubyplot/artist/image.rb

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -27,23 +27,22 @@ def imwrite(path)
2727
end
2828

2929
def export_pixels(x, y, columns, rows, map)
30-
# TODO: set offset
3130
@pixel_array = []
3231
map.size.times do
3332
@pixel_array.push([])
3433
end
3534
flat_pix_array = Rubyplot.backend.export_pixels(@image, x, y, columns, rows, map)
3635
map.size.times do |channel|
3736
rows.times do |row|
38-
@pixel_array[channel].push(flat_pix_array[channel*@rows*@columns+@columns*row,@columns])
37+
@pixel_array[channel].push(flat_pix_array[(channel*rows*columns)+(columns*row),columns])
3938
end
4039
end
4140
@pixel_array.flatten!(1) if map.size==1
4241
@pixel_array
4342
end
4443

4544
def import_pixels(x, y, columns, rows, map, pixels)
46-
Rubyplot.backend.import_pixels(@image, x, y, columns, rows, map, pixels.flatten)
45+
Rubyplot.backend.import_pixels(@image, x, y, columns, rows, map, pixels.to_a.flatten)
4746
end
4847
end # class Image
4948
end # module Artist

0 commit comments

Comments
 (0)