Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

How to convert GridImageItem to JPEGImageItem with java #108

Open
javading opened this issue Jan 19, 2022 · 0 comments
Open

How to convert GridImageItem to JPEGImageItem with java #108

javading opened this issue Jan 19, 2022 · 0 comments

Comments

@javading
Copy link

javading commented Jan 19, 2022

My main code is as follows:

`

HEIF heif = new HEIF();
heif.load("/root/1.heic");
ImageItem primaryImage = heif.getPrimaryImage();
List<byte[]> imageSequenceSampleDatas = new ArrayList<>();

if (primaryImage instanceof GridImageItem) {
	GridImageItem gridImageItem = (GridImageItem) primaryImage;
	// Go through the grid
	for (int rowIndex = 0; rowIndex < gridImageItem.getRowCount(); rowIndex++) {
		for (int columnIndex = 0; columnIndex < gridImageItem.getColumnCount(); columnIndex++) {
			// We assume that the image items are HEVC
			HEVCImageItem hevcImageItem = (HEVCImageItem) gridImageItem.getImage(columnIndex, rowIndex);
		 //   byte[] decoderConfig = hevcImageItem.getDecoderConfig().getConfig();
			byte[] imageData1 = hevcImageItem.getItemDataAsArray();

			JPEGDecoderConfig decoderConfig = new JPEGDecoderConfig(newHeif, decoderConfigData);
			JPEGImageItem jpegImageItem = new JPEGImageItem(newHeif, new Size(width, height), decoderConfig, imageData1);

			newHeif.setPrimaryImage(jpegImageItem);
			newHeif.setMajorBrand(HEIF.BRAND_JPEG);
			newHeif.addCompatibleBrand(HEIF.BRAND_JPEG);

			newHeif.save("/root/1-1.jpg");
		}
	}
}`
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant