# 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
var fw = new FileWriter.open(path)
# Write bitmap header
for x in [0..self.bitmap_header.length[ do
- fw.write(self.bitmap_header[x].ascii.to_s)
+ fw.write(self.bitmap_header[x].code_point.to_s)
end
# Write dib header
for x in [0..self.dib_header.length[ do
- fw.write(self.dib_header[x].ascii.to_s)
+ fw.write(self.dib_header[x].code_point.to_s)
end
# Write color table (if any)
# Write data (no padding for now)
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)
- fw.write(red.ascii.to_s)
- fw.write(green.ascii.to_s)
- fw.write(blue.ascii.to_s)
+ var green = (pixel & 0x00FF00) >> 8
+ var blue = pixel & 0x000000FF
+ fw.write(red.code_point.to_s)
+ fw.write(green.code_point.to_s)
+ fw.write(blue.code_point.to_s)
end
end
fw.close
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