Skip to content

Instantly share code, notes, and snippets.

@openize-heic-gists
openize-heic-gists / heic-to-png.java
Created April 10, 2025 15:32
Read HEIC file into BufferedImage in Java and save it to PNG using Java ImageIO
import java.awt.image.BufferedImage;
import javax.imageio.ImageIO;
import openize.heic.decoder.HeicImage;
import openize.io.IOFileStream;
import openize.io.IOMode;
try (IOFileStream fs = new IOFileStream("filename.heic", IOMode.READ))
{
HeicImage image = HeicImage.load(fs);
@openize-heic-gists
openize-heic-gists / heic-collection-to-png.java
Created April 10, 2025 15:31
Convert HEIC collection to a set of PNG files programatically in Java
import java.awt.image.BufferedImage;
import javax.imageio.ImageIO;
import openize.heic.decoder.HeicImage;
import openize.io.IOFileStream;
import openize.io.IOMode;
try (IOFileStream fs = new IOFileStream("filename.heic", IOMode.READ))
{
HeicImage image = HeicImage.load(fs);
@openize-heic-gists
openize-heic-gists / heic-to-png-using-BufferedImage.java
Created April 10, 2025 15:29
Read HEIC file into BufferedImage in Java and save it to JPEG using Java ImageIO
import java.awt.image.BufferedImage;
import javax.imageio.ImageIO;
import openize.heic.decoder.HeicImage;
import openize.io.IOFileStream;
import openize.io.IOMode;
try (IOFileStream fs = new IOFileStream("filename.heic", IOMode.READ))
{
HeicImage image = HeicImage.load(fs);
@openize-heic-gists
openize-heic-gists / heic-to-argb32-pixels.java
Created April 10, 2025 15:24
Read HEIC File into integer array in Java
import openize.heic.decoder.HeicImage;
import openize.io.IOFileStream;
import openize.io.IOMode;
try (IOFileStream fs = new IOFileStream("filename.heic", IOMode.READ))
{
HeicImage image = HeicImage.load(fs);
int[] pixels = image.getInt32Array(openize.heic.decoder.PixelFormat.Argb32);
}
@openize-heic-gists
openize-heic-gists / heic-to-png-using-bitmap.cs
Last active April 14, 2025 13:14
Convert HEIC to PNG programmatically using System.Drawing.Common.Bitmap in .NET
// Open the HEIC file named "filename.heic" in read mode using FileStream.
using (var fs = new FileStream("filename.heic", FileMode.Open))
{
// Load the HEIC image from the file stream into a HeicImage object.
HeicImage image = HeicImage.Load(fs);
// Extract the pixel data from the HEIC image in the ARGB32 format, storing it in an int array.
var pixels = image.GetInt32Array(Heic.Decoder.PixelFormat.Argb32);
// Retrieve the width and height of the HEIC image.
var width = (int)image.Width;
@openize-heic-gists
openize-heic-gists / heic-collection-to-png.cs
Last active April 14, 2025 13:14
Convert HEIC collection to a set of PNG files programmatically in .NET
// Open the HEIC file named "filename.heic" in read mode using FileStream.
using (var fs = new FileStream("filename.heic", FileMode.Open))
{
// Load the HEIC image from the file stream into a HeicImage object.
HeicImage image = HeicImage.Load(fs);
// For each frame of the image do the following:
foreach (var key in image.Frames.Keys)
{
// Retrieve the width and height of the HEIC image.
@openize-heic-gists
openize-heic-gists / heic-to-png.cs
Last active April 14, 2025 13:14
Convert HEIC to PNG programmatically using System.Windows.Media.Imaging.WriteableBitmap in .NET
// Open the HEIC file named "filename.heic" in read mode using FileStream.
using (var fs = new FileStream("filename.heic", FileMode.Open))
{
// Load the HEIC image from the file stream into a HeicImage object.
HeicImage image = HeicImage.Load(fs);
// Extract the pixel data from the HEIC image in the BGRA32 format, storing it in a byte array.
var pixels = image.GetByteArray(Heic.Decoder.PixelFormat.Bgra32);
// Retrieve the width and height of the HEIC image.
var width = (int)image.Width;
@openize-heic-gists
openize-heic-gists / heic-to-jpg.cs
Last active April 14, 2025 13:14
Convert HEIC to JPG programmatically using System.Windows.Media.Imaging.WriteableBitmap in .NET
// Open the HEIC file named "filename.heic" in read mode using FileStream.
using (var fs = new FileStream("filename.heic", FileMode.Open))
{
// Load the HEIC image from the file stream into a HeicImage object.
HeicImage image = HeicImage.Load(fs);
// Extract the pixel data from the HEIC image in the BGRA32 format, storing it in a byte array.
var pixels = image.GetByteArray(Heic.Decoder.PixelFormat.Bgra32);
// Retrieve the width and height of the HEIC image.
var width = (int)image.Width;
@openize-heic-gists
openize-heic-gists / heic-to-argb32-pixels.cs
Last active April 14, 2025 13:14
Read HEIC file into int array with Argb32 data in .NET
// Open the HEIC file named "filename.heic" using FileStream.
using (var fs = new FileStream("filename.heic", FileMode.Open))
{
// Load the HEIC image from the file stream into a HeicImage object.
HeicImage image = HeicImage.Load(fs);
// Extract pixel data from the HEIC image in the ARGB32 format and store it in an integer array.
int[] pixels = image.GetInt32Array(Heic.Decoder.PixelFormat.Argb32);
}