考虑引入lcmsnet库,对CMYK色彩空间图像提供ICC校正
Nobody has claimed this yet.
Assessment
- Difficulty
- 5/5
- Estimated time
- Over a week
- Newbie friendliness
- 35/100
- Issue type
- Bug
- Clarity
- Mostly clear
- Activity status
- Quiet
- Tech stack
- csharp
- Domain
- computer-graphics
Research direction
Start by reproducing the CMYK color issue with the linked JPG sample and the provided JPX-CMYK.zip sample, then inspect the current FreeImage handling of CMYK components and ICC data. Compare whether Libjpeg, OpenJpegDotNet, and lcmsnet can provide the needed extraction and conversion; done means CMYK JPG and JPX images are rendered with ICC correction rather than appearing color-shifted.
Written by the indexing model from the issue text.
Description
目前补丁丁没有考虑ICC配置文件。所以cmyk色彩空间的jpg和jpx图像大多是偏色的(有些情况甚至没读ICC数据)。
我不清楚freeimage是否支持解析jpg和jpx的CMYK分量,如果不支持的话,可能需要Libjpeg和OpenJpegDotNet库来提取原始分量,然后才能用lcmsnet校正(你还得自己编译一个lcms.dll)。
这里有jpg cmyk样本了,我再提供一个jpx cmyk样本
下面是AI写的调用lcmsnet的代码,配合notBald的LibJPEGv9.net和OpenJpegDotNet已经测试通过。
Profile profile = null;
if (info.ICCProfile != null)
{
try
{
profile = Profile.Open(info.ICCProfile); //读取PDF里面的icc
}
catch { }
}
if (profile == null)
{
string iccfilename = "xxxx.USWebCoatedSWOP.icc";
Assembly assembly = Assembly.GetExecutingAssembly();
Stream stream = assembly.GetManifestResourceStream(iccfilename);
byte[] defaultICC = stream.ToByteArray();
profile = Profile.Open(defaultICC);
}
using var rgbprofile = Profile.Create_sRGB();
using (profile)
{
//创建transform,从cmyk转为bgra
//渲染意图:INTENT_PERCEPTUAL 保持视觉一致性(默认),适合照片类图像
//标志位: 无标志
using var transform = Transform.Create(profile, Cms.TYPE_CMYK_8, rgbprofile, Cms.TYPE_BGRA_8, Intent.Perceptual, CmsFlags.None);
byte[] rgbBytes = new byte[cmykBytes.Length];
transform.DoTransform(cmykBytes, rgbBytes, info.Width * info.Height);
// 写入Bitmap
bmp = new Bitmap(info.Width, info.Height, PixelFormat.Format32bppArgb);
var rect = new Rectangle(0, 0, info.Width, info.Height);
var bitmapData = bmp.LockBits(rect, ImageLockMode.WriteOnly, bmp.PixelFormat);
int srcStride = info.Width * 4;
int dstStride = Math.Abs(bitmapData.Stride);
Parallel.For(0, info.Height, y =>
{
IntPtr dst = bitmapData.Scan0 + y * dstStride;
int srcOffset = y * srcStride;
Marshal.Copy(rgbBytes, srcOffset, dst, srcStride);
});
bmp.UnlockBits(bitmapData);
}
- Dominant language
- C#
- Stars
- 12.7k
- Forks
- 1.6k
- PR merge metrics
- No merged PRs in 30d
Contributor guide
No contributing guide indexed for this repository
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
More from wmjordan/PDFPatcher
-
360查杀 Open缺陷
Difficulty 4/5 3-5 days Newbie friendliness 35/100
wmjordan/PDFPatcher#314 · 1 comment ·
-
希望添加自定义显示字体的功能 Open书签 改进
wmjordan/PDFPatcher#311 · 3 comments · 1 assignee ·
-
打印预览 Open改进 重复
Difficulty 5/5 Over a week Newbie friendliness 25/100
wmjordan/PDFPatcher#310 · 1 comment ·
-
改进
wmjordan/PDFPatcher#308 · 3 comments · 1 assignee ·
-
取图 缺陷
Difficulty 4/5 3-5 days Newbie friendliness 42/100
wmjordan/PDFPatcher#305 · 5 comments ·
All issues in wmjordan/PDFPatcher
Similar issues
-
Difficulty 2/5 1-3 hours Newbie friendliness 86/100
-
:watch: Not Triaged 11.0 fundamentals/subsvc
Difficulty 2/5 1-3 hours Newbie friendliness 92/100
dotnet/AspNetCore.Docs#37699 ·
-
Difficulty 2/5 1-3 hours Newbie friendliness 72/100
SubtitleEdit/subtitleedit#15108 · 1 comment ·
-
area/docs-content Bug pulumi/docs
Difficulty 1/5 1-3 hours Newbie friendliness 94/100
-
agentic-workflows untriaged
Difficulty 2/5 1-3 hours Newbie friendliness 76/100