It would be great if you add a DPI setting into PdfImage, like:
inline void SetDpi( pdf_uint16 dpi );
with private member in PdfImage
pdf_uint16 m_dpi;
and
void PdfImage::SetImageData( unsigned int nWidth, unsigned int nHeight,
unsigned int nBitsPerComponent, PdfInputStream* pStream,
const TVecFilters & vecFilters )
{
const unsigned int w = std::round( (double) nWidth / (double) m_dpi * 72.0 );
const unsigned int h = std::round( (double) nHeight / (double) m_dpi * 72.0 );
m_rRect.SetWidth( w );
m_rRect.SetHeight( h );
this->GetObject()->GetDictionary().AddKey( "Width", PdfVariant( static_cast<pdf_int64>(nWidth) ) );
this->GetObject()->GetDictionary().AddKey( "Height", PdfVariant( static_cast<pdf_int64>(nHeight) ) );
this->GetObject()->GetDictionary().AddKey( "BitsPerComponent", PdfVariant( static_cast<pdf_int64>(nBitsPerComponent) ) );
PdfVariant var;
m_rRect.ToVariant( var );
this->GetObject()->GetDictionary().AddKey( "BBox", var );
this->GetObject()->GetStream()->Set( pStream, vecFilters );
}
void PdfImage::SetImageDataRaw( unsigned int nWidth, unsigned int nHeight,
unsigned int nBitsPerComponent, PdfInputStream* pStream )
{
const unsigned int w = std::round( (double) nWidth / (double) m_dpi * 72.0 );
const unsigned int h = std::round( (double) nHeight / (double) m_dpi * 72.0 );
m_rRect.SetWidth( w );
m_rRect.SetHeight( h );
this->GetObject()->GetDictionary().AddKey( "Width", PdfVariant( static_cast<pdf_int64>(nWidth) ) );
this->GetObject()->GetDictionary().AddKey( "Height", PdfVariant( static_cast<pdf_int64>(nHeight) ) );
this->GetObject()->GetDictionary().AddKey( "BitsPerComponent", PdfVariant( static_cast<pdf_int64>(nBitsPerComponent) ) );
PdfVariant var;
m_rRect.ToVariant( var );
this->GetObject()->GetDictionary().AddKey( "BBox", var );
this->GetObject()->GetStream()->SetRawData( pStream, -1 );
}
With these changes images in my PDFs look perfect, I set DPI to 150 and PDFs look amazing...