Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #================================================================
- # FUNÇÕES
- #================================================================
- GetPixel = Win32API.new('BFunc', 'BitmapGetPixel', 'lllp', 'l')
- SetPixel = Win32API.new('BFunc', 'BitmapSetPixel', 'lllp', 'l')
- #================================================================
- # CRIA BITMAP PARA OS TESTES
- #================================================================
- bitmap = Bitmap.new(10, 10)
- bitmap.set_pixel(0, 0, Color.new(255, 255, 0))
- #================================================================
- # TESTE DE GET PIXEL
- #================================================================
- #B, G, R, A
- px = [0, 0, 0, 0].pack('C4')
- y = GetPixel.(bitmap.object_id << 1, 0, 0, px)
- if y.zero?
- puts "Falha: GetPixel"
- else
- puts "Pixel [BGRA] em 0,0: " + px.unpack("C4").join(", ")
- end
- #================================================================
- # TESTE DE SET PIXEL
- #================================================================
- #B, G, R, A
- px = [255, 0, 0, 255].pack('C4') # Azul RGBA(0, 0, 255, 255)
- y = SetPixel.(bitmap.object_id << 1, 0, 0, px)
- if y.zero?
- puts "Falha: SetPixel"
- else
- c = bitmap.get_pixel(0, 0)
- puts "Sucesso: SetPixel: #{c.red}, #{c.green}, #{c.blue}, #{c.alpha}"
- end
- #================================================================
- # PARA
- #================================================================
- loop { Graphics.update }
Advertisement
Add Comment
Please, Sign In to add comment