2013-12-17 43 views
0

我需要将PDF转换为透明度的GIF。我在official site上发现了一些代码示例,但结果与预期不符。常见的问题是透明度下降。AbcPdf pdf保持透明度的GIF转换

我尝试下面的代码:

using (var doc = new Doc()) { 
      doc.Read(source); 
      doc.Rendering.SaveAlpha = true; 
      // the following lines from the official site. 
      // And this is showing blue background if I set this. 
      // But I don't need this blue background. 
      // Do not set anything special won't give good result. 

      //doc.Color.SetRgb(0, 0, 255); // blue background ... 
      //doc.FillRect(); // ... so you can see transparency 

      doc.Rendering.Save(destination); 
      doc.Clear(); 
     } 

请帮助,如果任何人有这样的经验研究。谢谢

回答

2

Rendering.SaveAlpha属性不适用于GIF。

GIF文件中的颜色定义存储在调色板中,而不是通道。调色板可以包含多达256种颜色,其中一种颜色设置为透明。不同于使用alpha通道,没有透明度。每个像素将是不透明的颜色或透明。

要保留Alpha通道,您需要呈现其他格式,例如PNG,BMP,TIFF(灰度,RGB和CMYK)或Photoshop PSD。如果结果看起来不错,请将其转换为透明的GIF,但我希望您会发现一些透明度信息将会丢失。这是不可避免的。

+0

我不专注于AbcPdf。我需要转换可能的任何其他工具或库。 – alex