Results 1 to 24 of 24

Thread: how to create heif,hif format picture by vb6?vb6 webp

  1. #1

    Thread Starter
    PowerPoster
    Join Date
    Jan 2020
    Posts
    5,541

    how to create heif,hif format picture by vb6?vb6 webp

    libheif/libheif at master · strukturag/libheif
    https://github.com/strukturag/libhei...master/libheif

    HEIF Image Extensions - Microsoft Apps
    https://apps.microsoft.com/detail/9p...ab&hl=en&gl=NL

    use this can show hif picture by wic,how to load png file,and save as heic/hif format?webp format?

  2. #2

    Thread Starter
    PowerPoster
    Join Date
    Jan 2020
    Posts
    5,541

    Re: how to create heif,hif format picture by vb6?vb6 webp

    jpgQuality=100%?301KB
    jpgQuality=NULL?149KB
    WHY? NOT SET ImageQuality:
    pEnc.CreateNewFrame pTFrame, Nothing
    hr = pTFrame.Initialize(Nothing)


    Code:
            If SaveFormat = "jpg" And jpgQuality <> 101 Then
                pEnc.CreateNewFrame pTFrame, ppbag
                
                Dim optImgQuality As PROPBAG2
                optImgQuality.pstrName = StrPtr("ImageQuality")
                Dim pv As Variant, bfb As Single
                bfb = jpgQuality / 100
                pv = bfb
                ppbag.Write 1&, optImgQuality, VarPtr(pv)
                hr = pTFrame.Initialize(ppbag)
            Else
                pEnc.CreateNewFrame pTFrame, Nothing
                hr = pTFrame.Initialize(Nothing)
            End If

  3. #3
    PowerPoster Arnoutdv's Avatar
    Join Date
    Oct 2013
    Posts
    6,747

    Re: how to create heif,hif format picture by vb6?vb6 webp

    jpgQuality=100%?301KB
    jpgQuality=NULL?149KB
    WHY? NOT SET ImageQuality:
    Maybe because the default is like 70% or 80% when nothing is specified?

  4. #4

    Thread Starter
    PowerPoster
    Join Date
    Jan 2020
    Posts
    5,541

    Re: how to create heif,hif format picture by vb6?vb6 webp

    Quote Originally Posted by Arnoutdv View Post
    Maybe because the default is like 70% or 80% when nothing is specified?
    When converting to Jpg without specifying a quality, GDIPLUS defaults to 90%

  5. #5
    PowerPoster Arnoutdv's Avatar
    Join Date
    Oct 2013
    Posts
    6,747

    Re: how to create heif,hif format picture by vb6?vb6 webp

    Then set it to 90% if you want to be sure it's 90%

  6. #6

    Thread Starter
    PowerPoster
    Join Date
    Jan 2020
    Posts
    5,541

    Re: how to create heif,hif format picture by vb6?vb6 webp

    Last edited by xiaoyao; Nov 20th, 2024 at 03:07 AM.

  7. #7
    PowerPoster
    Join Date
    Jul 2010
    Location
    NYC
    Posts
    7,667

    Re: how to create heif,hif format picture by vb6?vb6 webp

    IIRC WIC can only read HEIF, not save in it. libwebp isn't a WIC codec, you'd need to use that library directly.

  8. #8

  9. #9
    Fanatic Member
    Join Date
    Nov 2011
    Posts
    809

    Re: how to create heif,hif format picture by vb6?vb6 webp

    Quote Originally Posted by VanGoghGaming View Post
    The BitmapEncoder Class can create HEIF format.
    would be really great if someone who knows can create a small example that we can use to save images in the HEIF format.

  10. #10
    PowerPoster
    Join Date
    Jul 2010
    Location
    NYC
    Posts
    7,667

    Re: how to create heif,hif format picture by vb6?vb6 webp

    It looks like it just wraps WIC (the sample code uses WIC error codes).. has the save part been tried?

  11. #11

    Thread Starter
    PowerPoster
    Join Date
    Jan 2020
    Posts
    5,541

    Re: how to create heif,hif format picture by vb6?vb6 webp

    I LOAD A WEBP FILE,WHY guid,uuid not webp?

    pDecoder.GetFrame mFrame, pFrame
    pDecoder.GetContainerFormat tCF
    tcf UUID={1F122879-EBA0-4670-98C5-CF29F3B98711}
    1F122879, 0xEBA0, 0x4670, 0x98, 0xC5, 0xCF, 0x29, 0xF3, 0xB9, 0x87, 0x11
    https://github.com/webmproject/webp-...ain/src/uuid.h

    https://github.com/webmproject/webp-wic-codec

    Windows Imaging Component wrapper around libwebp for WebP support.
    Currently, only decoding is supported, but that allows to e.g., see the files
    in Windows PhotoViewer.

    Code:
            If imgFormat = 0 Then: If IsEqualIID(tCF, GUID_ContainerFormatWebp) Then imgFormat = WFF_WEBP
    Static iid As UUID
         If (iid.data1 = 0&) Then Call DEFINE_UUID(iid, &HE094B0E2, &H67F2, &H45B3, &HB0, &HEA, &H11, &H53, &H37, &HCA, &H7C, &HF3)
        GUID_ContainerFormatWebp = iid
    End Function
    Last edited by xiaoyao; Nov 20th, 2024 at 10:55 AM.

  12. #12

    Thread Starter
    PowerPoster
    Join Date
    Jan 2020
    Posts
    5,541

    Re: how to create heif,hif format picture by vb6?vb6 webp

    Quote Originally Posted by fafalone View Post
    It looks like it just wraps WIC (the sample code uses WIC error codes).. has the save part been tried?

    i try to load img by your wic lib,can show images,can save as png/jpg, but can't save as webp,heif format image.

    i have a dll can save as webp image.

    Code:
    Function ImageToWebp(ByVal ImageFile As String, ByVal SaveAsWebp As String, Optional jpgQuality As Long = 90, Optional ByRef BackWebpimgPtr As Long) As Boolean
            Dim Ret As Long
            Dim Buffer() As Byte
            Dim FromImgPtr As Long, BufferLenA As Long
            Static WebpimgPtr As Long
            Dim WebpLen As Long
            
            GetFileByte ImageFile, Buffer
            FromImgPtr = VarPtr(Buffer(0))
            BufferLenA = UBound(Buffer) + 1
    
            If WebpimgPtr <> 0 Then FreeWebpData WebpimgPtr
            Ret = SaveImageAsWebp(FromImgPtr, BufferLenA, VarPtr(WebpimgPtr), VarPtr(WebpLen), jpgQuality)
            If SaveAsWebp <> "" Then
                    SaveFileByAPI SaveAsWebp, WebpimgPtr, WebpLen
                    FreeWebpData WebpimgPtr
                    WebpimgPtr = 0
            Else
                BackWebpimgPtr = WebpimgPtr
            End If
            ImageToWebp = WebpLen > 0
    End Function
    Last edited by xiaoyao; Nov 20th, 2024 at 10:46 AM.

  13. #13
    Hyperactive Member -Franky-'s Avatar
    Join Date
    Dec 2022
    Location
    Bremen Germany
    Posts
    481

    Re: how to create heif,hif format picture by vb6?vb6 webp

    First you have to identify all WIC encoders/decoders. Only then can you see which image formats can be read or written. You can find an example on ActiveVB in the Up/Download area -> VBC_WIC_Codecs.zip As always without TLB.
    Last edited by -Franky-; Nov 20th, 2024 at 11:55 AM.

  14. #14
    PowerPoster
    Join Date
    Jul 2010
    Location
    NYC
    Posts
    7,667

    Re: how to create heif,hif format picture by vb6?vb6 webp

    If you've installed additional ones sure; but even if some new Win11 version started including it with the preinstalled set, they probably wouldn't even give it to 10, let alone 7.

    "Currently, only decoding is supported, but that allows to e.g., see the files
    in Windows PhotoViewer."

    That means you CANNOT SAVE WEBP WITH WIC USING THAT PROJECT, xaioyao.

    I swear this guy must have deep burning hatred for using a decent translator.

  15. #15

    Thread Starter
    PowerPoster
    Join Date
    Jan 2020
    Posts
    5,541

    Re: how to create heif,hif format picture by vb6?vb6 webp

    Quote Originally Posted by fafalone View Post
    If you've installed additional ones sure; but even if some new Win11 version started including it with the preinstalled set, they probably wouldn't even give it to 10, let alone 7.

    "Currently, only decoding is supported, but that allows to e.g., see the files
    in Windows PhotoViewer."

    That means you CANNOT SAVE WEBP WITH WIC USING THAT PROJECT, xaioyao.

    I swear this guy must have deep burning hatred for using a decent translator.
    IT'S COPY FROM HERE:
    https://github.com/webmproject/webp-wic-codec

  16. #16
    PowerPoster
    Join Date
    Jul 2010
    Location
    NYC
    Posts
    7,667

    Re: how to create heif,hif format picture by vb6?vb6 webp

    Yes and "only decoding supported" means it cannot save (encode).

    Decode = Open
    Encode = Save

    "Only decode" = Open only, no saving.

  17. #17
    Hyperactive Member -Franky-'s Avatar
    Join Date
    Dec 2022
    Location
    Bremen Germany
    Posts
    481

    Re: how to create heif,hif format picture by vb6?vb6 webp

    WIC can read and write Heic and Heif. Only read Webp. As already written. List all WIC encoders and decoders, then you will know. I can read the following image formats on my PC:
    BMP Decoder: *.bmp;*.dib;*.rle
    GIF Decoder: *.gif
    ICO Decoder: *.ico;*.icon
    CUR Decoder: *.cur
    JPEG Decoder: *.jpeg;*.jpe;*.jpg;*.jfif;*.exif
    PNG Decoder: *.png
    TIFF Decoder: *.tiff;*.tif
    DNG Decoder: *.dng
    WMPhoto Decoder: *.wdp;*.jxr
    DDS Decoder: *.dds
    Microsoft HEIF Decoder: *.heic;*.heif;*.hif;*.avci;*.heics;*.heifs;*.avcs;*.avif;*.avifs
    Microsoft Webp Decoder: *.webp
    Microsoft Raw Image Decoder: *.3fr;*.ari;*.arw;*.bay;*.cap;*.cr2;*.cr3;*.crw;*.dcs;*.dcr;*.drf;*.eip;*.erf;*.fff;*.iiq;*.k25;*.kd c;*.mef;*.mos;*.mrw;*.nef;*.nrw;*.orf;*.ori;*.pef;*.ptx;*.pxn;*.raf;*.raw;*.rw2;*.rwl;*.sr2;*.srf;*. srw;*.x3f;*.dng
    Microsoft Camera Raw Decoder: *.arw;*.cr2;*.crw;*.erf;*.kdc;*.mrw;*.nef;*.nrw;*.orf;*.pef;*.raf;*.raw;*.rw2;*.rwl;*.sr2;*.srw;*.dn g

    and write the following:
    BMP Encoder: *.bmp;*.dib;*.rle
    GIF Encoder: *.gif
    JPEG Encoder: *.jpeg;*.jpe;*.jpg;*.jfif;*.exif
    PNG Encoder: *.png
    TIFF Encoder: *.tiff;*.tif
    WMPhoto Encoder: *.wdp;*.jxr
    DDS Encoder: *.dds
    Microsoft HEIF Encoder: *.heic;*.heif;*.hif

    In addition to the free Heic/Heif codec from the Windows Store, you also need HEVC video extensions from the Windows Store: -> Images saved in HEIF files with the file extension ".heic" are compressed using the HEVC format. These files also require the HEVC video extensions package to be installed. If the HEVC video extensions package is not installed, the HEIF image extension cannot read or write HEIC files.

  18. #18

    Thread Starter
    PowerPoster
    Join Date
    Jan 2020
    Posts
    5,541

    Re: how to create heif,hif format picture by vb6?vb6 webp

    Quote Originally Posted by -Franky- View Post
    WIC can read and write Heic and Heif. Only read Webp. As already written. List all WIC encoders and decoders, then you will know. I can read the following image formats on my PC:
    BMP Decoder: *.bm
    Microsoft HEIF Encoder: *.heic;*.heif;*.hif

    In addition to the free Heic/Heif codec from the Windows Store, you also need HEVC video extensions from the Windows Store: -> Images saved in HEIF files with the file extension ".heic" are compressed using the HEVC format. These files also require the HEVC video extensions package to be installed. If the HEVC video extensions package is not installed, the HEIF image extension cannot read or write HEIC files.
    What code can be used to list all the encoders and decoders?
    This needs additional installation. Microsoft HEIF Encoder:

    25 years ago, our broadband speed was only 128kb/PS. That's because photoshop provides a function that can export multiple images. Format It displays GIF, PNG, JPG, the size of each image, and the clarity that can be viewed directly.
    Now the hard disk is big enough to consider this matter, but for some specialized image services, they are more important.

  19. #19
    Hyperactive Member -Franky-'s Avatar
    Join Date
    Dec 2022
    Location
    Bremen Germany
    Posts
    481

    Re: how to create heif,hif format picture by vb6?vb6 webp

    Quote Originally Posted by xiaoyao View Post
    What code can be used to list all the encoders and decoders?
    See post #13.

  20. #20
    PowerPoster VanGoghGaming's Avatar
    Join Date
    Jan 2020
    Location
    Eve Online - Mining, Missions & Market Trading!
    Posts
    2,644

    Wink Re: how to create heif,hif format picture by vb6?vb6 webp

    Quote Originally Posted by fafalone View Post
    It looks like it just wraps WIC (the sample code uses WIC error codes).. has the save part been tried?
    Can confirm that it successfully saves HEIF files but only after installing "HEVC Video Extensions" from the Microsoft Store (costs $0.99 lolz).

  21. #21
    Hyperactive Member -Franky-'s Avatar
    Join Date
    Dec 2022
    Location
    Bremen Germany
    Posts
    481

    Re: how to create heif,hif format picture by vb6?vb6 webp

    Technically speaking, there are two "HEVC Video Extensions" in the store. The one you find in the store costs $0.99. The one you can no longer find in the store is the "HEVC Video Extensions from Manufacturer" and that was free. There is a little trick to download the free extension from the store. Go to store.rg-adguard.net/ Change to ProductID and search for 9n4wgh0z6vhq. Download the Microsoft.HEVCVideoExtension_2.2.9.0_neutral_~_8wekyb3d8bbwe.appxbundle there and install it accordingly.

  22. #22
    PowerPoster
    Join Date
    Jul 2010
    Location
    NYC
    Posts
    7,667

    Re: how to create heif,hif format picture by vb6?vb6 webp

    Quote Originally Posted by VanGoghGaming View Post
    Can confirm that it successfully saves HEIF files but only after installing "HEVC Video Extensions" from the Microsoft Store (costs $0.99 lolz).
    and regular WIC doesn't after that?

  23. #23
    PowerPoster VanGoghGaming's Avatar
    Join Date
    Jan 2020
    Location
    Eve Online - Mining, Missions & Market Trading!
    Posts
    2,644

    Red face Re: how to create heif,hif format picture by vb6?vb6 webp

    I dunno, it probably should work as well, I just never played with WIC. The WinRT way is pretty slick though! You could give it a go using Franky's trick above, that works too!

  24. #24
    Hyperactive Member -Franky-'s Avatar
    Join Date
    Dec 2022
    Location
    Bremen Germany
    Posts
    481

    Re: how to create heif,hif format picture by vb6?vb6 webp

    Quote Originally Posted by fafalone View Post
    and regular WIC doesn't after that?
    For WIC to read and write .heic/.heif, the Heic/Heif codec and the HEVC video extensions from the store are required.
    Without "HEVC video extensions" WIC should give the error 0xC00D5212 = MF_E_TOPO_CODEC_NOT_FOUND when trying to read or write a HEIC/HEIF. The error is produced by the Media Foundation.
    Last edited by -Franky-; Nov 21st, 2024 at 06:10 AM.

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