1

Possible Duplicate:
Convert bitmap to PNG in-memory in C++ (win32)

I have a BMP file as a char* buffer. I want to convert this BMP file to a PNG file in-memory. I have tried it, and searched around a bit, but I couldn't find anything useful.

I can assume Windows XP or later, no .NET and C99.

Community
  • 1
  • 1
orlp
  • 112,504
  • 36
  • 218
  • 315

2 Answers2

1

ImageMagick has a C API. I would assume, since it lets you perform various transformations on images, that those images are kept in memory, so you should be able to just load it as BMP and eventually save it as PNG.

Vlad
  • 18,195
  • 4
  • 41
  • 71
0

In memory means, you probably have to do it yourself. You have to understand the headers of both BMP and PNG files. After you successfully create the header, you can copy data but data is not stored in the same form in BMP and PNG so it is quite time consuming task.

Another way to do it, is use an external tool and call it from C code to do the conversion. However the in-memory problem will be in question.

TheTechGuy
  • 16,560
  • 16
  • 115
  • 136