From: David Webber on


"Peter Olcott" <NoSpam(a)OCR4Screen.com> wrote in message
news:JpednSihRNSi7hPWnZ2dnUVZ_j6dnZ2d(a)giganews.com...
>
> "Tom Serface" <tom(a)camaswood.com> wrote in message
> news:e9SFSItuKHA.4492(a)TK2MSFTNGP05.phx.gbl...

>> In that case CImage would work great for you. It can read, convert, and
>> save any of the GDI+ types.
>
> I don't think that it can handle TIFF files,

Yes it can. See ImageFormatTIFF

Dave

--
David Webber
Mozart Music Software
http://www.mozart.co.uk
For discussion and support see
http://www.mozart.co.uk/mozartists/mailinglist.htm

From: Tom Serface on
It can do any of the types that GDI+ can do so TIFF is include. However,
there are lots of formats to TIFF (like JPEG) so some of them may not work.
You'll want to do exception catching around the use of the class.

Tom

"Peter Olcott" <NoSpam(a)OCR4Screen.com> wrote in message
news:JpednSihRNSi7hPWnZ2dnUVZ_j6dnZ2d(a)giganews.com...
>
> "Tom Serface" <tom(a)camaswood.com> wrote in message
> news:e9SFSItuKHA.4492(a)TK2MSFTNGP05.phx.gbl...
>> In that case CImage would work great for you. It can read, convert, and
>> save any of the GDI+ types.
>
> I don't think that it can handle TIFF files, but that its OK. It is far
> less hassle than the GDI+ stuff. It only took me about an hour to fully
> implement as opposed to ten hours to halfway implement. The one thing that
> was holding me up with the GDI+ stuff was that to get an HBITMAP, I had to
> provide a background color. I can't see why it needs to know this.
>
>>
>> Tom
>>
>> "Peter Olcott" <NoSpam(a)OCR4Screen.com> wrote in message
>> news:crydnUAuO991QRDWnZ2dnUVZ_hqdnZ2d(a)giganews.com...
>>>
>>> "Tom Serface" <tom(a)camaswood.com> wrote in message
>>> news:Ols4NLouKHA.3896(a)TK2MSFTNGP02.phx.gbl...
>>>>I use GDI+ from C++ and it works just fine if you do, as many have
>>>>suggested, include the right libs. I also use the CImage class:
>>>>
>>>> http://msdn.microsoft.com/en-us/library/bwea7by5(VS.80).aspx
>>>>
>>>> that does a lot of the work for you. There are lots of interesting
>>>> articles on the web about this ATL class. I find it very easy to use.
>>>> It supports the same image types as GDI+ as you'd expect.
>>>>
>>>> Tom
>>>
>>> The main thing (and possibly the only thing) that I need from GDI+ is to
>>> read and write PNG files.
>>>
>>>>
>>>> "Peter Olcott" <NoSpam(a)OCR4Screen.com> wrote in message
>>>> news:W7mdncFCK47CsRHWnZ2dnUVZ_v-dnZ2d(a)giganews.com...
>>>>> All of the links that I have found say they are showing you how to use
>>>>> GDI+ from C++, by they actually show you how to use GDI+ from C, not
>>>>> C++. For example they show you how to modify the WinMain() function.
>>>>> There is no WinMain() function in my MFC code.
>>>>>
>>>>> I want to be able to load and save PNG files and BMP files. Since
>>>>> Windows now does this, I would prefer to use Windows instead of any
>>>>> third party library.
>>>>>
>>>
>>>
>
>
From: Joseph M. Newcomer on
See below...
On Wed, 3 Mar 2010 08:50:18 -0600, "Peter Olcott" <NoSpam(a)OCR4Screen.com> wrote:

>
>"Tom Serface" <tom(a)camaswood.com> wrote in message
>news:eL%23ygLtuKHA.3408(a)TK2MSFTNGP06.phx.gbl...
>> Here's a tiny code snippet:
>>
>> CImage image;
>> image.Load(csMyGraphicFile); // Don't need to know type at
>> this point
>> HRESULT hr =
>> image.Save(csPNGPath,Gdiplus::ImageFormatPNG);
>> if(SUCCEEDED(hr)) // It worked
>>
>> Tom
>
>Ah that is how you test to see if it worked, good I will add
>this to my code. Also apparently it can infer the file save
>type from the filename suffix, thus the explicit type does
>not seem to be required. Since I am getting the filename
>suffix from a common dialogbox, I can count on it being
>correct.
****
Actually, it probably opens the file and looks at the header. GIF, TIFF, PNG, and JPEG
files all have distinctly different header information which can be detected.
joe
****
>
>>
>> "Peter Olcott" <NoSpam(a)OCR4Screen.com> wrote in message
>> news:crydnUAuO991QRDWnZ2dnUVZ_hqdnZ2d(a)giganews.com...
>>>
>>> "Tom Serface" <tom(a)camaswood.com> wrote in message
>>> news:Ols4NLouKHA.3896(a)TK2MSFTNGP02.phx.gbl...
>>>>I use GDI+ from C++ and it works just fine if you do, as
>>>>many have suggested, include the right libs. I also use
>>>>the CImage class:
>>>>
>>>> http://msdn.microsoft.com/en-us/library/bwea7by5(VS.80).aspx
>>>>
>>>> that does a lot of the work for you. There are lots of
>>>> interesting articles on the web about this ATL class. I
>>>> find it very easy to use. It supports the same image
>>>> types as GDI+ as you'd expect.
>>>>
>>>> Tom
>>>
>>> The main thing (and possibly the only thing) that I need
>>> from GDI+ is to read and write PNG files.
>>>
>>>>
>>>> "Peter Olcott" <NoSpam(a)OCR4Screen.com> wrote in message
>>>> news:W7mdncFCK47CsRHWnZ2dnUVZ_v-dnZ2d(a)giganews.com...
>>>>> All of the links that I have found say they are showing
>>>>> you how to use GDI+ from C++, by they actually show you
>>>>> how to use GDI+ from C, not C++. For example they show
>>>>> you how to modify the WinMain() function. There is no
>>>>> WinMain() function in my MFC code.
>>>>>
>>>>> I want to be able to load and save PNG files and BMP
>>>>> files. Since Windows now does this, I would prefer to
>>>>> use Windows instead of any third party library.
>>>>>
>>>
>>>
>
Joseph M. Newcomer [MVP]
email: newcomer(a)flounder.com
Web: http://www.flounder.com
MVP Tips: http://www.flounder.com/mvp_tips.htm
From: Ian Harvey on
On 4/03/2010 1:33 AM, Peter Olcott wrote:
> ...
> The one thing that was holding me up
> with the GDI+ stuff was that to get an HBITMAP, I had to
> provide a background color. I can't see why it needs to know
> this.

The Gdiplus image (represented by the Image/Bitmap object) may have
transparent regions - a feature of Gdiplus is that it supports images
that have an alpha channel.

GDI support for transparency is rather limited, so you need to nominate
a colour that will bleed through the transparent regions of your bitmap,
ahead of the actual display of the bitmap.

If your Gdiplus bitmap has no transparency you don't need to worry about
the background colour - you won't be able to see it!