RMagick を使用して、大きな PNG ファイルをタイルにトリミングしています。元の PNG ファイルは、背景が透明な線画です。線のエッジは、ジャギーを減らすためにアルファ ブレンドされます。タイル (これも PNG ファイル) はアルファ ブレンドされていないため、見栄えが悪くなります。タイルのアルファ チャネルを保持するにはどうすればよいですか?
コードは次のとおりです。
big_image = Image.read(png_file)[0]
0.upto(tileset['width'] - 1) do |x|
0.upto(tileset['height'] - 1) do |y|
# Snip the code that sets tile_filename
# Find the region to crop
left = x * 256
# The Y axis goes bottom to top
bottom = tileset['height'] * 256
top = bottom - ((1 + y) * 256)
tile = big_image.crop(left, top, 256, 256)
tile.write(tile_filename)
end
end
メソッドを確認しました-と.alpha?
の両方に対して true を返します。また、両方のオブジェクトを呼び出してみました。役に立ちませんでした。big_image
tile
.alpha(ActivateAlphaChannel)