Warning: file_get_contents(/data/phpspider/zhask/data//catemap/7/sqlite/3.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Imagemagick 使用RMagick裁剪图像可消除抗锯齿_Imagemagick_Rmagick - Fatal编程技术网

Imagemagick 使用RMagick裁剪图像可消除抗锯齿

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

我正在使用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 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)
;这没用