• Some users have recently had their accounts hijacked. It seems that the now defunct EVGA forums might have compromised your password there and seems many are using the same PW here. We would suggest you UPDATE YOUR PASSWORD and TURN ON 2FA for your account here to further secure it. None of the compromised accounts had 2FA turned on.
    Once you have enabled 2FA, your account will be updated soon to show a badge, letting other members know that you use 2FA to protect your account. This should be beneficial for everyone that uses FSFT.

convert grayscale to jpeg?c++

intelbrain

Limp Gawd
Joined
Aug 3, 2001
Messages
313
i have to work on a project that take raw images and convert to jpeg. Is there any sample code that i can look at? or any other suggestion welcome. I'm doing it in c++.

Thanks
 
Need more details.

1.) Are you implementing your own engine to convert, or can you use libraries?
2.) Detail what raw image format you are actually working with.
3.) Is this homework? ;)

edit: Lord Of Shadows had a good point. You can use something like imagemagick or netpbm.
 
I would just use an image library to handle all the work. (Unless you enjoy reading file format docs) I'm pretty sure imagemagick will do the job, but there are likely many other choices. ;o)
 
First, clarify your problem statement.

It sounds like you have a pile of image files in some format and you want to convert them to another format (JPEG).

If that's the case, it's a 2-step process.

1. Get a program that converts one file to JPEG
2. Write a script to wrap that up (batch file, perl, python, whatever)

If you can solve the problem that way, then C++, much as I tolerate it, is the wrong tool.

It's like posting:

I need to pick up a gallon of milk. Do you have any helicopter schematics?
 
I think he has to code it, in which case, if allowed to use other libs...do the sane thing and either use:

1. libjpeg/png/or whatever format OR

2. Some type of aforementioned lib that has conversion routines as well. This is uber simple, since you just have to link to those libs, include their header(s), and then call them according to API docs.
 
i have to code it using c++, basicly a program to take images say .bmp and convert them to jpeg files. I;m still looking for the lib.
 
intelbrain said:
i have to code it using c++, basicly a program to take images say .bmp and convert them to jpeg files. I;m still looking for the lib.

I thought you said raw to jpeg? Anyway... imagemagick or more specifically imagemagick's c++ interface magick++.

I wouldnt think it would be hard to go specifically from bmp to jpeg yourself if thats all that is required. (I believe jpeg has huffman encoding regardless if compressed or not though)

Code:
// compile me:
// cl magic.cpp /EHsc /link CORE_RL_magick_.lib CORE_RL_Magick++_.lib X11.lib

#include <iostream>
#include <Magick++.h>

using namespace std;
using namespace Magick;

int main(int argc, char *argv[])
{
	InitializeMagick(*argv);
	Image image;

	image.read("image.bmp");
	image.write("image.jpeg");
	return 0;
}
 
well i'm working on a project that take images from a camera. I think the images are raw, i was looking at c# code and it seems pretty easy.
 
Back
Top