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
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.
Re: how to create heif,hif format picture by vb6?vb6 webp
Originally Posted by fafalone
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.
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.
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.
Re: how to create heif,hif format picture by vb6?vb6 webp
Originally Posted by fafalone
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.
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.
Re: how to create heif,hif format picture by vb6?vb6 webp
Originally Posted by -Franky-
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.
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.
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!
Re: how to create heif,hif format picture by vb6?vb6 webp
Originally Posted by fafalone
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.