mirror of
https://github.com/SleepingInsomniac/pixelfaucet
synced 2025-01-29 08:34:35 +01:00
Use out instead of uninitialized/pointer
This commit is contained in:
parent
5b9a5571e2
commit
2d44da33b4
1 changed files with 2 additions and 13 deletions
|
@ -102,12 +102,7 @@ module PF
|
||||||
# Sample a color at an *x* and *y* position
|
# Sample a color at an *x* and *y* position
|
||||||
def sample(x : Int, y : Int)
|
def sample(x : Int, y : Int)
|
||||||
raw_pixel = peak(x, y)
|
raw_pixel = peak(x, y)
|
||||||
|
LibSDL.get_rgb(raw_pixel, format, out r, out g, out b)
|
||||||
r = uninitialized UInt8
|
|
||||||
g = uninitialized UInt8
|
|
||||||
b = uninitialized UInt8
|
|
||||||
|
|
||||||
LibSDL.get_rgb(raw_pixel, format, pointerof(r), pointerof(g), pointerof(b))
|
|
||||||
Pixel.new(r, g, b)
|
Pixel.new(r, g, b)
|
||||||
end
|
end
|
||||||
|
|
||||||
|
@ -120,13 +115,7 @@ module PF
|
||||||
def sample(x : Int, y : Int, alpha : Boolean)
|
def sample(x : Int, y : Int, alpha : Boolean)
|
||||||
return sample(x, y) unless alpha
|
return sample(x, y) unless alpha
|
||||||
raw_pixel = pixel_pointer(x, y).value
|
raw_pixel = pixel_pointer(x, y).value
|
||||||
|
LibSDL.get_rgba(raw_pixel, format, out r, out g, out b, out a)
|
||||||
r = uninitialized UInt8
|
|
||||||
g = uninitialized UInt8
|
|
||||||
b = uninitialized UInt8
|
|
||||||
a = uninitialized UInt8
|
|
||||||
|
|
||||||
LibSDL.get_rgba(raw_pixel, format, pointerof(r), pointerof(g), pointerof(b), pointerof(a))
|
|
||||||
Pixel.new(r, g, b, a)
|
Pixel.new(r, g, b, a)
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|
Loading…
Add table
Reference in a new issue