Imagemagick 使用RMagick裁剪图像可消除抗锯齿
我正在使用RMagick将一个大的PNG文件裁剪成平铺。原始PNG文件是具有透明背景的线条艺术;线边缘是alpha混合的,以减少锯齿。瓷砖(也是PNG文件)不是alpha混合的,它们看起来很难看。如何在平铺中保留alpha通道 代码如下:Imagemagick 使用RMagick裁剪图像可消除抗锯齿,imagemagick,rmagick,Imagemagick,Rmagick,我正在使用RMagick将一个大的PNG文件裁剪成平铺。原始PNG文件是具有透明背景的线条艺术;线边缘是alpha混合的,以减少锯齿。瓷砖(也是PNG文件)不是alpha混合的,它们看起来很难看。如何在平铺中保留alpha通道 代码如下: big_image = Image.read(png_file)[0] 0.upto(tileset['width'] - 1) do |x| 0.upto(tileset['height'] - 1) do |y| # Snip the cod
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?
方法——对于big\u image
和tile
,它都返回true。我还尝试在两个对象上调用.alpha(ActivateAlphaChannel)
;这没用