Yes, all RC6-Img-Loading-Methods accept either a passed FileName or a ByteArray (in the same Variant-ByRef-Parameter).
There's an auto-detection of the ImageType (directly on the ImageByte-Content),
which works for: *.png, *.jpg, *.gif, *.bmp, *.svg and *.svgz
Originally Posted by Steve Grant
Resize said image at very high quality whilst maintaining aspect ratio.
Display in picturebox.
See the code below ... (the most versatile ImageLoading is sitting behind the Cairo.ImageList)
Originally Posted by Steve Grant
Secondly does RC6 yet have the ability to Read/Write audio metadata inc Coverart for the popular formats?
No, whilst it has sound-support for MS-CoreAudio (on Windows),
the cMP3Resource-Class only retrieves the following info (in ByRef-Params) via this method:
Sub GetMP3Info(FileNameOrByteArray, Freq As Long, Channels As Long, ID3Offs As Long, [DurationEstimateMS As Long])
Ok here some code for Image-Loading and DownScaling (whilst keeping the Aspect-Ratio).
If you want to adapt to a PictureBox (instead of the Form), then just replace all the Me.refs with your PicBox-Identifier.
Code:
Option Explicit
Private B() As Byte
Private Sub Form_Load()
Caption = "Resize Me"
B = New_c.FSO.ReadByteContent("c:\temp\large.jpg")
End Sub
Private Sub Form_Resize()
Dim W: W = Me.ScaleX(Me.ScaleWidth, Me.ScaleMode, vbPixels)
Dim H: H = Me.ScaleY(Me.ScaleHeight, Me.ScaleMode, vbPixels)
Set Me.Picture = Cairo.ImageList.AddImage("", B, W, H, True).Picture
End Sub
Very many thanks Olaf. I have compared the RC6 method against the GDI+ and feel the latter is slightly better at this size (300 x 300). Could you have a look?
Indeed I invite anyone who sees this to take a look. After all it could be my old tired eyes.
I feel the RC6 method gives results similar to the best I have been able to squeeze out of the WIA. Which means on most images it is fine but on some, like this, it gets caught out.
I would fully like to embrace RC6 if it should be possible.
'RC6
B = New_c.FSO.ReadByteContent(Filename)
' Set pic1.Picture = Cairo.ImageList.AddImage("", B, W, H, True).Picture
pic1.AutoRedraw = True
Cairo.ImageList.AddImage "myImage", B 'Load image to Bytes with no Resize
With Cairo.CreateSurface(W, H)
.CreateContext.RenderSurfaceContent "myImage", 0, 0, W, H, CAIRO_FILTER_BEST
.DrawToDC pic1.hDC
End With
This way it looks almost the same to me. Olaf will be able to give better directions though.
They're pretty close to my eyes, but I think the edge goes to GDI+ too. I've tried loading the image at 2x the required size, then paint it using the "best" Cairo quality, and at that point I struggle to see a difference between Cairo and GDI+ even zoomed in significantly:
Code:
Dim W: W = 600
Dim H: H = 600
Dim Filename As String: Filename = App.Path & "\Blow Up.jpg"
Caption = "RC6 Picture Test"
'RC6
B = New_c.FSO.ReadByteContent(Filename)
Cairo.ImageList.AddImage "img", B, W, H, True
With Cairo.CreateSurface(300, 300)
With .CreateContext
.RenderSurfaceContent "img", 0, 0, 300, 300, CAIRO_FILTER_BEST, , True
End With
.DrawToDC Me.pic1.hDC, , , , , , , , , , , True
End With
Your eyes might be better tuned to what you are looking for though!