Convert RGBA to bmp format

Magick++ is an object-oriented C++ interface to ImageMagick. Use this forum to discuss, make suggestions about, or report bugs concerning Magick++.
Post Reply
midas
Posts: 4
Joined: 2017-01-11T03:18:29-07:00
Authentication code: 1151

Convert RGBA to bmp format

Post by midas »

Can I get help in converting RGBA image to Bitmap?
snibgo
Posts: 12159
Joined: 2010-01-23T23:01:33-07:00
Authentication code: 1151
Location: England, UK

Re: Convert RGBA to bmp format

Post by snibgo »

Yes, you can.

Some more detail might help us to help you.
snibgo's IM pages: im.snibgo.com
midas
Posts: 4
Joined: 2017-01-11T03:18:29-07:00
Authentication code: 1151

Re: Convert RGBA to bmp format

Post by midas »

Please find below my code:

#include <Magick++.h>
#include <iostream>
#include <fstream>
#include <stdio.h>
#include "stdafx.h"


using namespace std;
using namespace Magick;
//#pragma warning(disable : 4996)

int main(int argc,char **argv)
{

InitializeMagick(*argv);

return 0;
}

When I build I get below error:
error LNK2019: unresolved external symbol "__declspec(dllimport) void __cdecl Magick::InitializeMagick(char const *)" (__imp_?InitializeMagick@Magick@@YAXPBD@Z) referenced in function _main

I have done below declarations in Project settings:
C\C++ -> General -> Addtn Include Directories -> ImageMagick-7.0.4-Q16\include

Linker-> General->Addtn Library Directories -> ImageMagick-7.0.4-Q16\lib
snibgo
Posts: 12159
Joined: 2010-01-23T23:01:33-07:00
Authentication code: 1151
Location: England, UK

Re: Convert RGBA to bmp format

Post by snibgo »

Okay, so you have a linker error when building your program. What toolchain are you using? I use Gnu C, part of Cygwin, and have no problems. I probably can't help, but perhaps you can say what toolchain you use (and search for that on these forums).
snibgo's IM pages: im.snibgo.com
midas
Posts: 4
Joined: 2017-01-11T03:18:29-07:00
Authentication code: 1151

Re: Convert RGBA to bmp format

Post by midas »

I use below platform toolset:
Visual Studio 2012 (v110)

Also, can you tell me what commands should I use to convert rgba files to bmp?
snibgo
Posts: 12159
Joined: 2010-01-23T23:01:33-07:00
Authentication code: 1151
Location: England, UK

Re: Convert RGBA to bmp format

Post by snibgo »

If your RGBA files are literally that, with no header, just pixels, something like this:

Code: Select all

convert -size 123x456 RGBA:in.bin out.bmp
... but with the correct size.
snibgo's IM pages: im.snibgo.com
midas
Posts: 4
Joined: 2017-01-11T03:18:29-07:00
Authentication code: 1151

Re: Convert RGBA to bmp format

Post by midas »

I would be writing it in C++ so let me know what functions should I call?

I searched on the net and found below snippet:
Magick::Blob blob(data, length);
Magick::Image image;
image.size("640x480")
image.magick("RGBA");
image.read(blob);
image.write("file.bmp");

Is this correct?
snibgo
Posts: 12159
Joined: 2010-01-23T23:01:33-07:00
Authentication code: 1151
Location: England, UK

Re: Convert RGBA to bmp format

Post by snibgo »

Sorry, I don't use Magick++.
snibgo's IM pages: im.snibgo.com
Post Reply