Results 1 to 8 of 8

Thread: VBRichClient Image sizing

  1. #1

    Thread Starter
    Fanatic Member
    Join Date
    Jul 2007
    Location
    Essex, UK.
    Posts
    578

    VBRichClient Image sizing

    Like a lot of others I am trying out RC6. The FSO replacement is amazing and it would really help to know if I can;

    Load an image file.
    Resize said image at very high quality whilst maintaining aspect ratio.
    Display in picturebox.

    At the moment I do it with GDI+ and the results are very very good, only FreeImage is better and you really have to look.

    Secondly does RC6 yet have the ability to Read/Write audio metadata inc Coverart for the popular formats?

  2. #2
    PowerPoster
    Join Date
    Jun 2013
    Posts
    7,219

    Re: VBRichClient Image sizing

    Quote Originally Posted by Steve Grant View Post
    ...it would really help to know if I can;

    Load an image file.
    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

    Quote Originally Posted by Steve Grant View Post
    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)

    Quote Originally Posted by Steve Grant View Post
    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
    HTH

    Olaf

  3. #3

    Thread Starter
    Fanatic Member
    Join Date
    Jul 2007
    Location
    Essex, UK.
    Posts
    578

    Re: VBRichClient Image sizing

    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.
    Attached Files Attached Files

  4. #4
    Fanatic Member
    Join Date
    Sep 2010
    Location
    Italy
    Posts
    678

    Re: VBRichClient Image sizing

    Code:
    '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.

  5. #5
    PowerPoster
    Join Date
    Aug 2010
    Location
    Canada
    Posts
    2,412

    Re: VBRichClient Image sizing

    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!

  6. #6
    PowerPoster
    Join Date
    Aug 2010
    Location
    Canada
    Posts
    2,412

    Re: VBRichClient Image sizing

    Ahh reexre beat me to it

  7. #7

    Thread Starter
    Fanatic Member
    Join Date
    Jul 2007
    Location
    Essex, UK.
    Posts
    578

    Re: VBRichClient Image sizing

    Both of you have come up trumps! With CAIRO_FILTER_BEST I can't see the difference either.

    So in order to rid myself of the GDI+ module;

    1) How to get the original image dimension?
    2) How to get the image type?

    Once again thank you so much.

    Hmmm can't give jpbro any rep at the moment.

  8. #8

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width