Gabz

RGSS Bitmap Manipulation In C++ // PT.2

Jul 29th, 2014
398
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Ruby 1.46 KB | None | 0 0
  1. #================================================================
  2. # FUNÇÕES
  3. #================================================================
  4. GetPixel = Win32API.new('BFunc', 'BitmapGetPixel', 'lllp', 'l')
  5. SetPixel = Win32API.new('BFunc', 'BitmapSetPixel', 'lllp', 'l')
  6.  
  7. #================================================================
  8. # CRIA BITMAP PARA OS TESTES
  9. #================================================================
  10. bitmap = Bitmap.new(10, 10)
  11. bitmap.set_pixel(0, 0, Color.new(255, 255, 0))
  12.  
  13. #================================================================
  14. # TESTE DE GET PIXEL
  15. #================================================================
  16.      #B, G, R, A
  17. px = [0, 0, 0, 0].pack('C4')
  18. y = GetPixel.(bitmap.object_id << 1, 0, 0, px)
  19.  
  20. if y.zero?
  21.   puts "Falha: GetPixel"
  22. else
  23.   puts "Pixel [BGRA] em 0,0: " + px.unpack("C4").join(", ")
  24. end
  25.  
  26. #================================================================
  27. # TESTE DE SET PIXEL
  28. #================================================================
  29.      #B,   G, R, A
  30. px = [255, 0, 0, 255].pack('C4') # Azul RGBA(0, 0, 255, 255)
  31. y = SetPixel.(bitmap.object_id << 1, 0, 0, px)
  32.  
  33. if y.zero?
  34.   puts "Falha: SetPixel"
  35. else
  36.   c = bitmap.get_pixel(0, 0)
  37.   puts "Sucesso: SetPixel: #{c.red}, #{c.green}, #{c.blue}, #{c.alpha}"
  38. end
  39.  
  40. #================================================================
  41. # PARA
  42. #================================================================
  43. loop { Graphics.update }
Advertisement
Add Comment
Please, Sign In to add comment