odin-blend2d

Odin bindings to Blend2D
Log | Files | Refs | README | LICENSE

imagecodec.odin (4163B)


      1 // This file is part of Blend2D project <https://blend2d.com>
      2 //
      3 // See blend2d.h or LICENSE.md for license and copyright information
      4 // SPDX-License-Identifier: Zlib
      5 package blend2d
      6 
      7 import "core:c"
      8 
      9 when ODIN_OS == .Windows {
     10 	foreign import lib "blend2d.lib"
     11 } else when ODIN_OS == .Darwin {
     12 	foreign import lib "libblend2d.a"
     13 } else when ODIN_OS == .Linux {
     14 	foreign import lib "libblend2d.a"
     15 }
     16 
     17 
     18 //! Image codec [C API].
     19 ImageCodecCore :: struct {
     20 	_d: ObjectDetail,
     21 }
     22 
     23 //! \cond
     24 //! Image codec [C API Virtual Function Table].
     25 ImageCodecVirt :: struct {
     26 	base:           ObjectVirtBase,
     27 	inspect_data:   proc "c" (impl: ^ImageCodecImpl, data: ^u8, size: c.size_t) -> u32,
     28 	create_decoder: proc "c" (impl: ^ImageCodecImpl, dst: ^ImageDecoderCore) -> Result,
     29 	create_encoder: proc "c" (impl: ^ImageCodecImpl, dst: ^ImageEncoderCore) -> Result,
     30 }
     31 
     32 //! Image codec [C API Impl].
     33 ImageCodecImpl :: struct {
     34 	//! \name Members
     35 	//! \{
     36 	
     37 	//! Virtual function table.
     38 	virt: ^ImageCodecVirt,
     39 
     40 	//! Image codec name like "PNG", "JPEG", etc...
     41 	name: StringCore,
     42 
     43 	//! Image codec vendor string, built-in codecs use "Blend2D" as a vendor string.
     44 	vendor: StringCore,
     45 
     46 	//! Mime types.
     47 	mime_type: StringCore,
     48 
     49 	//! Known file extensions used by this image codec separated by "|".
     50 	extensions: StringCore,
     51 
     52 	//! Image codec features.
     53 	features: u32,
     54 }
     55 
     56 @(default_calling_convention="c", link_prefix="bl_")
     57 foreign lib {
     58 	//! \endcond
     59 	image_codec_init                         :: proc(self: ^ImageCodecCore) -> Result ---
     60 	image_codec_init_move                    :: proc(self: ^ImageCodecCore, other: ^ImageCodecCore) -> Result ---
     61 	image_codec_init_weak                    :: proc(self: ^ImageCodecCore, other: ^ImageCodecCore) -> Result ---
     62 	image_codec_init_by_name                 :: proc(self: ^ImageCodecCore, name: cstring, size: c.size_t, codecs: ^ArrayCore) -> Result ---
     63 	image_codec_destroy                      :: proc(self: ^ImageCodecCore) -> Result ---
     64 	image_codec_reset                        :: proc(self: ^ImageCodecCore) -> Result ---
     65 	image_codec_assign_move                  :: proc(self: ^ImageCodecCore, other: ^ImageCodecCore) -> Result ---
     66 	image_codec_assign_weak                  :: proc(self: ^ImageCodecCore, other: ^ImageCodecCore) -> Result ---
     67 	image_codec_find_by_name                 :: proc(self: ^ImageCodecCore, name: cstring, size: c.size_t, codecs: ^ArrayCore) -> Result ---
     68 	image_codec_find_by_extension            :: proc(self: ^ImageCodecCore, name: cstring, size: c.size_t, codecs: ^ArrayCore) -> Result ---
     69 	image_codec_find_by_data                 :: proc(self: ^ImageCodecCore, data: rawptr, size: c.size_t, codecs: ^ArrayCore) -> Result ---
     70 	image_codec_inspect_data                 :: proc(self: ^ImageCodecCore, data: rawptr, size: c.size_t) -> u32 ---
     71 	image_codec_create_decoder               :: proc(self: ^ImageCodecCore, dst: ^ImageDecoderCore) -> Result ---
     72 	image_codec_create_encoder               :: proc(self: ^ImageCodecCore, dst: ^ImageEncoderCore) -> Result ---
     73 	image_codec_array_init_built_in_codecs   :: proc(self: ^ArrayCore) -> Result ---
     74 	image_codec_array_assign_built_in_codecs :: proc(self: ^ArrayCore) -> Result ---
     75 	image_codec_add_to_built_in              :: proc(codec: ^ImageCodecCore) -> Result ---
     76 	image_codec_remove_from_built_in         :: proc(codec: ^ImageCodecCore) -> Result ---
     77 }
     78 
     79 //! Image codec feature bits.
     80 ImageCodecFeatures :: enum u32 {
     81 	//! No features.
     82 	NO_FEATURES         = 0,
     83 
     84 	//! Image codec supports reading images (can create BLImageDecoder).
     85 	FEATURE_READ        = 1,
     86 
     87 	//! Image codec supports writing images (can create BLImageEncoder).
     88 	FEATURE_WRITE       = 2,
     89 
     90 	//! Image codec supports lossless compression.
     91 	FEATURE_LOSSLESS    = 4,
     92 
     93 	//! Image codec supports loosy compression.
     94 	FEATURE_LOSSY       = 8,
     95 
     96 	//! Image codec supports writing multiple frames (GIF).
     97 	FEATURE_MULTI_FRAME = 16,
     98 
     99 	//! Image codec supports IPTC metadata.
    100 	FEATURE_IPTC        = 268435456,
    101 
    102 	//! Image codec supports EXIF metadata.
    103 	FEATURE_EXIF        = 536870912,
    104 
    105 	//! Image codec supports XMP metadata.
    106 	FEATURE_XMP         = 1073741824,
    107 	FEATURE_FORCE_UINT  = 4294967295,
    108 }
    109