You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I've noticed that when working on images, I get those errors quite alot, it might be because the way we handle things are not optimal.
GC Warning: Repeated allocation of very large block (appr. size 1052672):
May lead to memory leak and poor performance
GC Warning: Repeated allocation of very large block (appr. size 409600):
May lead to memory leak and poor performance
GC Warning: Repeated allocation of very large block (appr. size 503808):
May lead to memory leak and poor performance
GC Warning: Repeated allocation of very large block (appr. size 692224):
May lead to memory leak and poor performance
Any clue if the below can be done better?
temp =IO::Memory.new(image_file)
canvas =StumpyPNG.read(temp)
temp.close
(0...canvas.height).each do |y| # make it darker
(0...canvas.width).each do |x|
curr = canvas[x, y]
canvas[x, y] =StumpyPNG::RGBA.from_rgb_n(
curr.r *0.549,
curr.g *0.549,
curr.b *0.549,
16
)
endend
alert =StumpyPNG.read("assets/alert.png")
alert_y =Math.max(0, canvas.height *0.365- alert.height //2).to_i
alert_x = (canvas.width - alert.width) //2.to_i
alert_offset = (Math.min(canvas.width, alert.width) - alert.width) //2.to_i
(0...Math.min(canvas.height, alert.height)).each do |y| # paste in alert
(alert_offset...alert.width - alert_offset).each do |x|
canvas[alert_x + x, alert_y + y] = alert[x, y]
endend
font =PCFParser::Font.from_file("assets/font.pcf")
canvas.text(
alert_x + (alert.width -8* alert_text.size) //2,
alert_y + alert.height //3+4,
alert_text,
font
) # print alert text
temp =IO::Memory.new
StumpyPNG.write(canvas, temp, color_type::rgb)
data = temp.to_slice
temp.close
data
The text was updated successfully, but these errors were encountered:
I've noticed that when working on images, I get those errors quite alot, it might be because the way we handle things are not optimal.
Any clue if the below can be done better?
The text was updated successfully, but these errors were encountered: