Thomas Hoevel wrote:
There shouldn't be duplicates either when the same filename is used for all XImage objects.
Unfortunately I create the image from a BITMAPINFO* (C++/CLI)
//PDFSharp does not support 16bit
Bitmap^ AdjustBitDepth(Bitmap^ image)
{
Bitmap^ newImage = nullptr;
switch (image->PixelFormat)
{
case PixelFormat::Format16bppRgb555:
newImage = image->Clone(System::Drawing::Rectangle(0, 0, image->Width, image->Height), PixelFormat::Format32bppRgb);
break;
case PixelFormat::Format16bppRgb565:
newImage = image->Clone(System::Drawing::Rectangle(0, 0, image->Width, image->Height), PixelFormat::Format32bppRgb);
break;
case PixelFormat::Format16bppArgb1555:
newImage = image->Clone(System::Drawing::Rectangle(0, 0, image->Width, image->Height), PixelFormat::Format32bppArgb);
break;
}
if (newImage == nullptr)
return image;
delete image;
return newImage;
}
////////////////////////////////////////////////////////////////////////////
XImage^ FromMetaRecord(BITMAPINFO* pInfo, BYTE* bitmapBytes)
{
Gdiplus::GpBitmap *bitmap = NULL;
Gdiplus::DllExports::GdipCreateBitmapFromGdiDib(pInfo, bitmapBytes, &bitmap);
System::Reflection::MethodInfo^ mi = Bitmap::typeid->GetMethod("FromGDIplus", System::Reflection::BindingFlags::Static | System::Reflection::BindingFlags::NonPublic);
Bitmap ^image = (Bitmap^)mi->Invoke(nullptr, gcnew cli::array<Object^> { IntPtr(bitmap) });
image = AdjustBitDepth(image);
XImage^ xImage = XImage::FromGdiPlusImage(image);
return xImage;
}
I am studying a methods to compare BITMAP objects to reuse the same XImage
Thomas Hoevel wrote:
BTW: do you get an increase of 50 kB for a document with 5 invoices?
Yes, its size grows proportional with page number and image size