"Cor" <no*@non.com> wrote in message news:<O#**************@TK2MSFTNGP10.phx.gbl>...
Hi John,
I never made a png file, but in the link I gave you I see this code,
I see it nowhere in your code ????
<<snip>> // Get the CLSID of the PNG encoder.
GetEncoderClsid(L"image/png", &encoderClsid);
stat = image->Save(L"Bird.png", &encoderClsid, NULL);
Thanks for your reply, however the example is odd because there is no
Save method for images which uses the Encoder Clsid.
Using 3 of the available Bitmap Save methods, makes no difference to
the output png file. The 3 methods are shown below. Test1.png, 2 and
3 are exactly the same.
Private Sub createPng
Dim strGifs(3) As String
Dim i, pos(3, 1) As Integer
Dim oBmpPng As Bitmap
Dim oGraphics As Graphics
Dim oImgTile As Image
Dim pngFormat As ImageFormat
Dim pngGuid As Guid
Dim pngCodec As ImageCodecInfo
Dim encoderParams As EncoderParameters
pngCodec = GetEncoder("image/png")
pngFormat = ImageFormat.Png
'Creates a 400 x 400 pixel Png file containing 4 Gifs. Each
Gif is 200 x 200
strGifs(0) = "TQ09NW04.gif"
strGifs(1) = "TQ09NW08.gif"
strGifs(2) = "TQ09NW24.gif"
strGifs(3) = "TQ09NW28.gif"
pos(0, 0) = 0 : pos(0, 1) = 0
pos(1, 0) = 0 : pos(1, 1) = 200
pos(2, 0) = 200 : pos(2, 1) = 0
pos(3, 0) = 200 : pos(3, 1) = 200
oBmpPng = New Bitmap(400, 400, PixelFormat.Format32bppRgb)
oGraphics = Graphics.FromImage(oBmpPng)
For i = 0 To 3
oImgTile = Image.FromFile(strFolder + strGifs(i))
oGraphics.DrawImage(oImgTile, pos(i, 0), pos(i, 1))
Next
oBmpPng.Save(strFolder + "test1.png")
oBmpPng.Save(strFolder + "test2.png", pngCodec, encoderParams)
oBmpPng.Save(strFolder + "test3.png", pngFormat)
oBmpPng.Dispose()
oGraphics.Dispose()
oImgTile.Dispose()
End Sub
Private Function GetEncoder(ByVal mimeType As String) As
Imaging.ImageCodecInfo
Dim encoders() As Imaging.ImageCodecInfo =
Imaging.ImageCodecInfo.GetImageEncoders()
Dim i As Integer
For i = 0 To encoders.Length - 1
If encoders(i).MimeType = mimeType Then
Return encoders(i)
End If
Next
End Function