# type, Int is used.
private fun set_value(array: Array[Int], start_index: Int, value: Int)
do
- array[start_index] = value.bin_and(0x000000FF)
- array[start_index + 1] = (value >> 8).bin_and(0x000000FF)
- array[start_index + 2] = (value >> 16).bin_and(0x000000FF)
- array[start_index + 3] = (value >> 24).bin_and(0x000000FF)
+ array[start_index] = value & 0x000000FF
+ array[start_index + 1] = (value >> 8) & 0x000000FF
+ array[start_index + 2] = (value >> 16) & 0x000000FF
+ array[start_index + 3] = (value >> 24) & 0x000000FF
end
# Saves the bitmap into a file
for y in [0..self.width[ do
var pixel = row[y]
var red = pixel >> 16
- var green = pixel.bin_and(0x00FF00) >> 8
- var blue = pixel.bin_and(0x000000FF)
+ var green = (pixel & 0x00FF00) >> 8
+ var blue = pixel & 0x000000FF
fw.write(red.ascii.to_s)
fw.write(green.ascii.to_s)
fw.write(blue.ascii.to_s)
for y in [0..self.width[ do
var pixel = row[y]
var red = pixel >> 16
- var green = pixel.bin_and(0x00FF00) >> 8
- var blue = pixel.bin_and(0x000000FF)
+ var green = (pixel & 0x00FF00) >> 8
+ var blue = pixel & 0x000000FF
var lum = (0.2126 * red.to_f + 0.7152 * green.to_f + 0.0722 * blue.to_f).to_i
pixel = lum * 256 * 256 + lum * 256 + lum
self.data[x][y] = pixel