How to get the ICC bytes out of CPDF_ICCBasedCS

17 views
Skip to first unread message

Roman Wueger

unread,
Apr 7, 2021, 5:13:20 AM4/7/21
to pdfium
Hello,

how do I get the icc bytes out of CPDF_ICCBasedCS, so I can use it with ImageMagick?

Something like buffer[1024] an iterator + length or similar?

Thanks in advance
Roman

David Tejnora

unread,
Apr 7, 2021, 11:33:08 AM4/7/21
to Roman Wueger, pdfium
Hello, 
  You have to get stream, load it and get span with data. You have to check all return values.
  
My sample:
   const CPDF_Stream* pStream = mColorSpace->GetArray()->GetStreamAt(1);
   RetainPtr<CPDF_StreamAcc> stream=pdfium::MakeRetain<CPDF_StreamAcc>(pStream);
   stream->LoadAllDataFiltered();
   pdfium::span<const uint8_t> iccProfile=stream->GetSpan();

David

st 7. 4. 2021 v 11:13 odesílatel Roman Wueger <roman....@gmail.com> napsal:
--
You received this message because you are subscribed to the Google Groups "pdfium" group.
To unsubscribe from this group and stop receiving emails from it, send an email to pdfium+un...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/pdfium/7AD2C3D2-148D-4095-8CC2-C020C8AEDB8B%40gmail.com.

Roman Wueger

unread,
Apr 7, 2021, 11:34:48 AM4/7/21
to David Tejnora, pdfium
Hello David,

thank you I will try your suggestion.

Best Regards
Roman

Am 07.04.2021 um 17:33 schrieb David Tejnora <david....@gmail.com>:



roman....@gmail.com

unread,
Jun 10, 2021, 7:32:44 AM6/10/21
to David Tejnora, pdfium

Hi David,

 

Thanks and sorry for the long response, but I don’t get the ICC data out of it.

 

Here is how I get the colorspace:

FPDF_IMAGEOBJ_METADATA metadata;

auto ret = FPDFImageObj_GetImageMetadata(pageObject, page.get(), &metadata);

if (ret) {

//auto iccProfile = static_cast<CPDF_ICCBasedCS *>(metadata.colorspace); // HERE I WANT TO GET THE ICC DATA

//if (iccProfile) {

//    if (StringInfo *stringInfo = BlobToStringInfo(iccProfile->->GetStream()->, iccProfile.size)) {

//        SetImageProfile(pImage, "icc", stringInfo, exception.get());

//    }

//}

}

 

Best Regards

Roman

David Tejnora

unread,
Jun 10, 2021, 10:35:57 AM6/10/21
to Roman Wueger, pdfium
Hello,
I expected that "pageObject" is CPDF_PageObject. You have to get colorspace from this object:
const CPDF_ColorState* colorState=aPageObject->m_ColorState;
Now select fill or stroke.
const CPDF_Color* fillColor=colorState->GetFillColor();
Select the colorspace, but m_pCS is protected and I can not find getter. Probably you have to add getter, or make it public (comment protected).
const CPDF_ColorSpace* fillColorSpace=fillColor ->m_pCS.Get();
And use it:
auto iccProfile = static_cast<CPDF_ICCBasedCS *>( fillColorSpace  );
...
David




čt 10. 6. 2021 v 13:32 odesílatel <roman....@gmail.com> napsal:
Reply all
Reply to author
Forward
0 new messages