-
June 1st, 2006, 08:36 AM
#1
Image format conversion
Hi ,
I am scanning an image and that image is in .dib format .
Now i need to convert that image to jpeg,tif,gif.
how can i convert dib to these formats ?
Note:
There is an option called save it as .bmp format .. so no issues when converting it to bitmap but i need to convert it other formats also.
Idea
is there any possiblity to use GDI+ to convert ?
waiting for ur reply .
Thanks,
Venrag
-
June 1st, 2006, 08:45 AM
#2
Re: Image format conversion
Yes, you can use GDI+ or other third party image libraries. Also, take a look at the articles at http://www.codeguru.com/Cpp/G-M/bitmap/. Some of them explain how to save to other formats.
-
June 1st, 2006, 08:47 AM
#3
Re: Image format conversion
You can do it with Image Class (GDI+).
/EDIT: Marc was faster
Cheers
-
June 1st, 2006, 10:29 AM
#4
Re: Image format conversion
Any other methos other than GDI
to convert a dib image to gif,jpg,tif
thank u
venrag
-
June 1st, 2006, 11:10 AM
#5
Re: Image format conversion
Originally Posted by venrag
Any other methos other than GDI
to convert a dib image to gif,jpg,tif
thank u
venrag
Why? What do you have against GDI ?
Cheers
-
June 1st, 2006, 11:34 PM
#6
Re: Image format conversion
I don't have any thing against GDI+.
I have a image which is scanned from the scanner and put in the View.
This image is in the format of dib.
I convert it in to bmp and save it in the disc.
Suppose I want to save this dib image that is in the view in to
gif,jpg or tif ,I have to first convert in to bmp and save it in the disc and
then convert it to gif using GDI+ Image.
what i want to do is to convert the dib Image from the view directly to
gif,jpg ,tif.
For this I have asked whether we have any other method.
thank u
venrag
-
June 2nd, 2006, 01:59 AM
#7
Re: Image format conversion
Have you checked the articles at http://www.codeguru.com/Cpp/G-M/bitmap/ like I said in my first reply?
For example, take a look at http://www.codeguru.com/cpp/g-m/bitm...cle.php/c4915/ to save bitmaps to JPG files.
NOTE: I would not recommend to save photos to GIF format because the GIF format only supports 256 colors and is not really suitable for photos.
-
June 2nd, 2006, 02:58 AM
#8
Re: Image format conversion
Originally Posted by venrag
I don't have any thing against GDI+.
I have a image which is scanned from the scanner and put in the View.
This image is in the format of dib.
I convert it in to bmp and save it in the disc.
Suppose I want to save this dib image that is in the view in to
gif,jpg or tif ,I have to first convert in to bmp and save it in the disc and
then convert it to gif using GDI+ Image.
what i want to do is to convert the dib Image from the view directly to
gif,jpg ,tif.
For this I have asked whether we have any other method.
thank u
venrag
You don’t have to write to the disc you can create Image from stream ( Image::FromStream() ).
Cheers
-
June 2nd, 2006, 07:09 AM
#9
Re: Image format conversion
I have used the stream function.
Iam passing the
Code:
CWnd *pwnd=AfxGetMainWnd();
HWND hwnd =pwnd->GetSafeHwnd();
HDC hdc;
hdc=GetDC(hwnd);
Example_FromStream(hdc);
Inside Example_FromStream(hdc)
Graphics graphics(hdc);
Image* pImage1 = NULL;
Image* pImage2 = NULL;
IStorage* pIStorage = NULL;
IStream* pIStream1 = NULL;
IStream* pIStream2 = NULL;
HRESULT hr;
Status stat;
// Open an existing compound file, and get a pointer
// to its IStorage interface.
hr = StgOpenStorage(
L"CompoundFile.cmp",
NULL,
STGM_READ|STGM_SHARE_EXCLUSIVE,
NULL,
0,
&pIStorage);
if(FAILED(hr))
goto Exit;===>each time Iam getting failed
because hr=-ve value.
What is a CompoudFile.cmp
So I only I went for the filename method.
Canu helpme with Stream function
By the way I want to reduce the memory capacity of the image
so Iwant to convert it in to gif file
No problem with the reduction of the color.
thank u
-
June 2nd, 2006, 10:49 AM
#10
Re: Image format conversion
Hi I got the conversion
from bmp to jpg
using GDI+ without saving the image to the disc.
I have not used Stream method .
Instead I got the idea from the below link
http://www.codeguru.com/cpp/g-m/gdi/...cle.php/c3661/
I have used CBitmap and Bitmap (GDI+) to get the handle of the
Image in the view.
"Thanks MarcG and GolanShahar"
I have tested the BMP with MSPAINT I am getting the jpeg format
memory size is correct.
When I convert to giff I am getting little bit difference.
Like in MSPAINT conversion 775kb -->35.5kb
In GDI+ --->55.5kb
I think this difference is because I have not reduced the color.
I have to find out that.
Thank u
venrag
-
June 2nd, 2006, 11:01 AM
#11
Re: Image format conversion
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|