C# iTextSharp Extracted CMYK images returns in RGB Format

旧街凉风 提交于 2019-12-11 21:14:42

问题


I am using iTextsharp to extracted images from epaper PDF files, the images in the PDF files are in CMYK format, but the extracted images are in RGB. Please advice on this. Thanks in advance

int xrefIdx = ((PRIndirectReference)obj).Number;
PdfObject pdfObj = doc.GetPdfObject(xrefIdx);
PdfStream str = (PdfStream)pdfObj;
byte[] bytes = PdfReader.GetStreamBytesRaw((PRStream)str);

using (System.IO.MemoryStream memStream = new System.IO.MemoryStream(bytes))
{
var rawImage = System.Drawing.Image.FromStream(memStream); 
rawImage.Save(@"e:\extractedimages.jpeg", ImageFormat.Jpeg);
}

回答1:


Unfortunately, .NET isn't really up to the job for what you need to do as it really only works in RGB. Please see this answer to another question (https://stackoverflow.com/a/1773496/7122) which has more details.



来源:https://stackoverflow.com/questions/19363265/c-sharp-itextsharp-extracted-cmyk-images-returns-in-rgb-format

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!