Click to See Complete Forum and Search --> : Image format conversion
venrag
June 1st, 2006, 09:36 AM
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
Marc G
June 1st, 2006, 09:45 AM
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.
golanshahar
June 1st, 2006, 09:47 AM
You can do it with Image Class (GDI+) (http://msdn.microsoft.com/library/default.asp?url=/library/en-us/gdicpp/GDIPlus/GDIPlusReference/Classes/Image.asp).
/EDIT: Marc was faster :D
Cheers
venrag
June 1st, 2006, 11:29 AM
Any other methos other than GDI
to convert a dib image to gif,jpg,tif
thank u
venrag
golanshahar
June 1st, 2006, 12:10 PM
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 ? :D
Cheers
venrag
June 2nd, 2006, 12:34 AM
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
Marc G
June 2nd, 2006, 02:59 AM
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/bitmap/capturing/article.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.
golanshahar
June 2nd, 2006, 03:58 AM
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() (http://msdn.microsoft.com/library/default.asp?url=/library/en-us/gdicpp/GDIPlus/GDIPlusReference/Classes/ImageClass/ImageMethods/FromStream_58stream_useEmbeddedColorManagement.asp) ).
Cheers
venrag
June 2nd, 2006, 08:09 AM
I have used the stream function.
Iam passing the
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
venrag
June 2nd, 2006, 11:49 AM
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/gdi/article.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
ovidiucucu
June 2nd, 2006, 12:01 PM
[ Moved thread ]
codeguru.com
Copyright Internet.com Inc., All Rights Reserved.