Create PDF file from Sprite or color array

I’ve found an easy looking tutorial how to create a pdf in c++:

Here’s a piece of code which draws an image on page:

auto stream = MakeObject<IO::MemoryStream>();
SharedPtr<Bitmap> bitmap = MakeObject<Bitmap>(200, 200);
SharedPtr<Graphics> graphics = Graphics::FromImage(bitmap);
graphics->Clear(System::Drawing::Color::get_Yellow());
graphics->FillRectangle(Brushes::get_Blue(), System::Drawing::Rectangle(0, 0, 200, 100));
bitmap->Save(stream, Imaging::ImageFormat::get_Bmp());

In my game I have an image drawn by user, stored in unsigned char* array, also accessible by Sprite object.

Is it possible to convert this data array to “Bitmap” or “Graphics” so I’d be able to create PDF from user drawn image?

That would depend on the Bitmap API that the PDF library provides. Check if it allows you to create an instance of Bitmap with raw data (RGB/RGBA or whatever order they may accept that data in).

Just found out the price of that library :smiley: Not worth it, I’d rather create a native code and pass the image there.