@@ -743,115 +743,6 @@ struct heif_error heif_context_encode_image(struct heif_context* ctx,
743
743
}
744
744
745
745
746
- struct heif_error heif_context_encode_grid (struct heif_context * ctx,
747
- struct heif_image ** tiles,
748
- uint16_t columns,
749
- uint16_t rows,
750
- struct heif_encoder * encoder,
751
- const struct heif_encoding_options * input_options,
752
- struct heif_image_handle ** out_image_handle)
753
- {
754
- if (!encoder || !tiles) {
755
- return Error (heif_error_Usage_error,
756
- heif_suberror_Null_pointer_argument).error_struct (ctx->context .get ());
757
- }
758
- else if (rows == 0 || columns == 0 ) {
759
- return Error (heif_error_Usage_error,
760
- heif_suberror_Invalid_parameter_value).error_struct (ctx->context .get ());
761
- }
762
-
763
- // TODO: Don't repeat this code from heif_context_encode_image()
764
- heif_encoding_options options;
765
- heif_color_profile_nclx nclx;
766
- set_default_encoding_options (options);
767
- if (input_options) {
768
- heif_encoding_options_copy (&options, input_options);
769
-
770
- if (options.output_nclx_profile == nullptr ) {
771
- auto input_nclx = tiles[0 ]->image ->get_color_profile_nclx ();
772
- if (input_nclx) {
773
- options.output_nclx_profile = &nclx;
774
- nclx.version = 1 ;
775
- nclx.color_primaries = (enum heif_color_primaries) input_nclx->get_colour_primaries ();
776
- nclx.transfer_characteristics = (enum heif_transfer_characteristics) input_nclx->get_transfer_characteristics ();
777
- nclx.matrix_coefficients = (enum heif_matrix_coefficients) input_nclx->get_matrix_coefficients ();
778
- nclx.full_range_flag = input_nclx->get_full_range_flag ();
779
- }
780
- }
781
- }
782
-
783
- // Convert heif_images to a vector of HeifPixelImages
784
- std::vector<std::shared_ptr<HeifPixelImage>> pixel_tiles;
785
- for (int i=0 ; i<rows*columns; i++) {
786
- pixel_tiles.push_back (tiles[i]->image );
787
- }
788
-
789
- // Encode Grid
790
- std::shared_ptr<ImageItem> out_grid;
791
- auto addGridResult = ImageItem_Grid::add_and_encode_full_grid (ctx->context .get (),
792
- pixel_tiles,
793
- rows, columns,
794
- encoder,
795
- options);
796
- if (addGridResult.error ) {
797
- return addGridResult.error .error_struct (ctx->context .get ());
798
- }
799
-
800
- out_grid = addGridResult.value ;
801
-
802
- // Mark as primary image
803
- if (ctx->context ->is_primary_image_set () == false ) {
804
- ctx->context ->set_primary_image (out_grid);
805
- }
806
-
807
- if (out_image_handle) {
808
- *out_image_handle = new heif_image_handle;
809
- (*out_image_handle)->image = std::move (out_grid);
810
- (*out_image_handle)->context = ctx->context ;
811
- }
812
-
813
- return heif_error_success;
814
- }
815
-
816
-
817
- struct heif_error heif_context_add_grid_image (struct heif_context * ctx,
818
- uint32_t image_width,
819
- uint32_t image_height,
820
- uint32_t tile_columns,
821
- uint32_t tile_rows,
822
- const struct heif_encoding_options * encoding_options,
823
- struct heif_image_handle ** out_grid_image_handle)
824
- {
825
- if (tile_rows == 0 || tile_columns == 0 ) {
826
- return Error (heif_error_Usage_error,
827
- heif_suberror_Invalid_parameter_value).error_struct (ctx->context .get ());
828
- }
829
- else if (tile_rows > 0xFFFF || tile_columns > 0xFFFF ) {
830
- return heif_error{heif_error_Usage_error,
831
- heif_suberror_Invalid_image_size,
832
- " Number of tile rows/columns may not exceed 65535" };
833
- }
834
-
835
- auto generateGridItemResult = ImageItem_Grid::add_new_grid_item (ctx->context .get (),
836
- image_width,
837
- image_height,
838
- static_cast <uint16_t >(tile_rows),
839
- static_cast <uint16_t >(tile_columns),
840
- encoding_options);
841
- if (generateGridItemResult.error ) {
842
- return generateGridItemResult.error .error_struct (ctx->context .get ());
843
- }
844
-
845
- if (out_grid_image_handle) {
846
- *out_grid_image_handle = new heif_image_handle;
847
- (*out_grid_image_handle)->image = generateGridItemResult.value ;
848
- (*out_grid_image_handle)->context = ctx->context ;
849
- }
850
-
851
- return heif_error_success;
852
- }
853
-
854
-
855
746
struct heif_error heif_context_add_overlay_image (struct heif_context * ctx,
856
747
uint32_t image_width,
857
748
uint32_t image_height,
@@ -906,63 +797,6 @@ struct heif_error heif_context_add_overlay_image(struct heif_context* ctx,
906
797
}
907
798
908
799
909
- struct heif_error heif_context_add_tiled_image (struct heif_context * ctx,
910
- const struct heif_tiled_image_parameters * parameters,
911
- const struct heif_encoding_options * options, // TODO: do we need this?
912
- const struct heif_encoder * encoder,
913
- struct heif_image_handle ** out_grid_image_handle)
914
- {
915
- if (out_grid_image_handle) {
916
- *out_grid_image_handle = nullptr ;
917
- }
918
-
919
- Result<std::shared_ptr<ImageItem_Tiled>> gridImageResult;
920
- gridImageResult = ImageItem_Tiled::add_new_tiled_item (ctx->context .get (), parameters, encoder);
921
-
922
- if (gridImageResult.error != Error::Ok) {
923
- return gridImageResult.error .error_struct (ctx->context .get ());
924
- }
925
-
926
- if (out_grid_image_handle) {
927
- *out_grid_image_handle = new heif_image_handle;
928
- (*out_grid_image_handle)->image = gridImageResult.value ;
929
- (*out_grid_image_handle)->context = ctx->context ;
930
- }
931
-
932
- return heif_error_success;
933
- }
934
-
935
-
936
- struct heif_error heif_context_add_image_tile (struct heif_context * ctx,
937
- struct heif_image_handle * tiled_image,
938
- uint32_t tile_x, uint32_t tile_y,
939
- const struct heif_image * image,
940
- struct heif_encoder * encoder)
941
- {
942
- if (auto tili_image = std::dynamic_pointer_cast<ImageItem_Tiled>(tiled_image->image )) {
943
- Error err = tili_image->add_image_tile (tile_x, tile_y, image->image , encoder);
944
- return err.error_struct (ctx->context .get ());
945
- }
946
- #if WITH_UNCOMPRESSED_CODEC
947
- else if (auto unci = std::dynamic_pointer_cast<ImageItem_uncompressed>(tiled_image->image )) {
948
- Error err = unci->add_image_tile (tile_x, tile_y, image->image );
949
- return err.error_struct (ctx->context .get ());
950
- }
951
- #endif
952
- else if (auto grid_item = std::dynamic_pointer_cast<ImageItem_Grid>(tiled_image->image )) {
953
- Error err = grid_item->add_image_tile (tile_x, tile_y, image->image , encoder);
954
- return err.error_struct (ctx->context .get ());
955
- }
956
- else {
957
- return {
958
- heif_error_Usage_error,
959
- heif_suberror_Unspecified,
960
- " Cannot add tile to a non-tiled image"
961
- };
962
- }
963
- }
964
-
965
-
966
800
struct heif_error heif_context_add_unci_image (struct heif_context * ctx,
967
801
const struct heif_unci_image_parameters * parameters,
968
802
const struct heif_encoding_options * encoding_options,
0 commit comments