mirror of
https://github.com/SleepingInsomniac/pixelfaucet
synced 2025-01-28 07:58:32 +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
|
||||
def sample(x : Int, y : Int)
|
||||
raw_pixel = peak(x, y)
|
||||
|
||||
r = uninitialized UInt8
|
||||
g = uninitialized UInt8
|
||||
b = uninitialized UInt8
|
||||
|
||||
LibSDL.get_rgb(raw_pixel, format, pointerof(r), pointerof(g), pointerof(b))
|
||||
LibSDL.get_rgb(raw_pixel, format, out r, out g, out b)
|
||||
Pixel.new(r, g, b)
|
||||
end
|
||||
|
||||
|
@ -120,13 +115,7 @@ module PF
|
|||
def sample(x : Int, y : Int, alpha : Boolean)
|
||||
return sample(x, y) unless alpha
|
||||
raw_pixel = pixel_pointer(x, y).value
|
||||
|
||||
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))
|
||||
LibSDL.get_rgba(raw_pixel, format, out r, out g, out b, out a)
|
||||
Pixel.new(r, g, b, a)
|
||||
end
|
||||
|
||||
|
|
Loading…
Add table
Reference in a new issue