Store icon in BGRA format so runtime conversion is not necessary.

This commit is contained in:
josh committed 2020-12-19 12:31:07 -05:00
1 parent 7678c00d25
commit e102c0c6f6
5 files changed
+540 -118

No files matched your search

+20
View File
@@ -0,0 +1,20 @@
#!/usr/bin/env ruby
require "fileutils"
ICON = "share/jes/icons/jes-32x32.png"
OUTFILE = "src/jes/gui/icon.d"
system(*%W[convert #{ICON} bgra:icon.bgra])
icon_bgra = File.binread("icon.bgra")
FileUtils.rm_f("icon.bgra")
File.open(OUTFILE, "wb") do |fh|
fh.puts "module jes.gui.icon;"
fh.puts
fh.puts "const ubyte[] icon_32x32_bgra = ["
icon_bgra.bytes.each_slice(8) do |bytes|
fh.puts " #{bytes.map {|b| sprintf("0x%02xu,", b)}.join(" ")}"
end
fh.puts "];"
end