75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
|
# File 'lib/sdl.rb', line 75
def setCursor(bitmap,white,black,transparent,inverted,hot_x=0,hot_y=0)
if bitmap.w % 8 != 0 then
raise SDL::Error,"width of cursor must be muliple of 8"
end
white=SDL.color2int(white,bitmap.format)
black=SDL.color2int(black,bitmap.format)
transparent=SDL.color2int(transparent,bitmap.format)
inverted=SDL.color2int(inverted,bitmap.format)
data=[]
mask=[]
i=-1
for y in 0..(bitmap.h-1)
for x in 0..(bitmap.w-1)
if x%8 == 0 then
i+=1
data[i]=mask[i]=0
else
data[i] <<= 1
mask[i] <<= 1
end
case bitmap.getPixel(x,y)
when white
mask[i] |= 0x01
when black
data[i] |= 0x01
mask[i] |= 0x01
when transparent
when inverted
data[i] |= 0x01
end
end
end
setCursor_imp data.pack('C*'),mask.pack('C*'),bitmap.w,bitmap.h,hot_x,hot_y
end
|