// AUTO GENERATED FILE, DO NOT EDIT.
//
// Generated by `package:ffigen`.
// ignore_for_file: type=lint, unused_import
import 'dart:ffi' as ffi;
import 'package:objective_c/objective_c.dart' as objc;

@ffi.Native<ffi.Pointer<__CFAllocator>>()
external final ffi.Pointer<__CFAllocator> kCFAllocatorDefault;

@ffi.Native<ffi.Void Function(ffi.Pointer<ffi.Void>)>()
external void CFRelease(ffi.Pointer<ffi.Void> cf);

@ffi.Native<CFDictionaryKeyCallBacks>()
external final CFDictionaryKeyCallBacks kCFTypeDictionaryKeyCallBacks;

@ffi.Native<CFDictionaryValueCallBacks>()
external final CFDictionaryValueCallBacks kCFTypeDictionaryValueCallBacks;

@ffi.Native<
  CFDictionaryRef Function(
    ffi.Pointer<__CFAllocator>,
    ffi.Pointer<ffi.Pointer<ffi.Void>>,
    ffi.Pointer<ffi.Pointer<ffi.Void>>,
    ffi.Long,
    ffi.Pointer<CFDictionaryKeyCallBacks>,
    ffi.Pointer<CFDictionaryValueCallBacks>,
  )
>()
external CFDictionaryRef CFDictionaryCreate(
  ffi.Pointer<__CFAllocator> allocator,
  ffi.Pointer<ffi.Pointer<ffi.Void>> keys,
  ffi.Pointer<ffi.Pointer<ffi.Void>> values,
  int numValues,
  ffi.Pointer<CFDictionaryKeyCallBacks> keyCallBacks,
  ffi.Pointer<CFDictionaryValueCallBacks> valueCallBacks,
);

@ffi.Native<
  CFDataRef Function(
    ffi.Pointer<__CFAllocator>,
    ffi.Pointer<ffi.UnsignedChar>,
    ffi.Long,
  )
>()
external CFDataRef CFDataCreate(
  ffi.Pointer<__CFAllocator> allocator,
  ffi.Pointer<ffi.UnsignedChar> bytes,
  int length,
);

@ffi.Native<CFMutableDataRef Function(ffi.Pointer<__CFAllocator>, ffi.Long)>()
external CFMutableDataRef CFDataCreateMutable(
  ffi.Pointer<__CFAllocator> allocator,
  int capacity,
);

@ffi.Native<ffi.Long Function(CFDataRef)>()
external int CFDataGetLength(CFDataRef theData);

@ffi.Native<ffi.Pointer<ffi.UnsignedChar> Function(CFDataRef)>()
external ffi.Pointer<ffi.UnsignedChar> CFDataGetBytePtr(CFDataRef theData);

@ffi.Native<ffi.Size Function(CGImageRef)>()
external int CGImageGetWidth(CGImageRef image);

@ffi.Native<ffi.Size Function(CGImageRef)>()
external int CGImageGetHeight(CGImageRef image);

@ffi.Native<ffi.Size Function(CGImageRef)>()
external int CGImageGetBitsPerComponent(CGImageRef image);

@ffi.Native<CGColorSpaceRef Function(CGImageRef)>()
external CGColorSpaceRef CGImageGetColorSpace(CGImageRef image);

@ffi.Native<ffi.Uint32 Function(CGImageRef)>()
external int CGImageGetBitmapInfo(CGImageRef image);

@ffi.Native<ffi.Void Function(CGContextRef, objc.CGRect, CGImageRef)>()
external void CGContextDrawImage(
  CGContextRef c,
  objc.CGRect rect,
  CGImageRef image,
);

@ffi.Native<ffi.Void Function(CGContextRef, ffi.Int32)>(
  symbol: 'CGContextSetInterpolationQuality',
)
external void _CGContextSetInterpolationQuality(CGContextRef c, int quality);

void CGContextSetInterpolationQuality(
  CGContextRef c,
  CGInterpolationQuality quality,
) => _CGContextSetInterpolationQuality(c, quality.value);

@ffi.Native<
  CGContextRef Function(
    ffi.Pointer<ffi.Void>,
    ffi.Size,
    ffi.Size,
    ffi.Size,
    ffi.Size,
    CGColorSpaceRef,
    ffi.Uint32,
  )
>()
external CGContextRef CGBitmapContextCreate(
  ffi.Pointer<ffi.Void> data,
  int width,
  int height,
  int bitsPerComponent,
  int bytesPerRow,
  CGColorSpaceRef space,
  int bitmapInfo,
);

@ffi.Native<CGImageRef Function(CGContextRef)>()
external CGImageRef CGBitmapContextCreateImage(CGContextRef context);

@ffi.Native<CGImageSourceRef Function(CFDataRef, CFDictionaryRef)>()
external CGImageSourceRef CGImageSourceCreateWithData(
  CFDataRef data,
  CFDictionaryRef options,
);

@ffi.Native<CGImageRef Function(CGImageSourceRef, ffi.Size, CFDictionaryRef)>()
external CGImageRef CGImageSourceCreateImageAtIndex(
  CGImageSourceRef isrc,
  int index,
  CFDictionaryRef options,
);

@ffi.Native<ffi.Pointer<objc.CFString>>()
external ffi.Pointer<objc.CFString> kCGImageDestinationLossyCompressionQuality;

@ffi.Native<
  CGImageDestinationRef Function(
    CFMutableDataRef,
    ffi.Pointer<objc.CFString>,
    ffi.Size,
    CFDictionaryRef,
  )
>()
external CGImageDestinationRef CGImageDestinationCreateWithData(
  CFMutableDataRef data,
  ffi.Pointer<objc.CFString> type,
  int count,
  CFDictionaryRef options,
);

@ffi.Native<
  ffi.Void Function(CGImageDestinationRef, CGImageRef, CFDictionaryRef)
>()
external void CGImageDestinationAddImage(
  CGImageDestinationRef idst,
  CGImageRef image,
  CFDictionaryRef properties,
);

@ffi.Native<ffi.Bool Function(CGImageDestinationRef)>()
external bool CGImageDestinationFinalize(CGImageDestinationRef idst);

final class __CFAllocator extends ffi.Opaque {}

final class CFDictionaryKeyCallBacks extends ffi.Struct {
  @ffi.Long()
  external int version;

  external ffi.Pointer<
    ffi.NativeFunction<
      ffi.Pointer<ffi.Void> Function(
        ffi.Pointer<__CFAllocator> allocator,
        ffi.Pointer<ffi.Void> value,
      )
    >
  >
  retain;

  external ffi.Pointer<
    ffi.NativeFunction<
      ffi.Void Function(
        ffi.Pointer<__CFAllocator> allocator,
        ffi.Pointer<ffi.Void> value,
      )
    >
  >
  release;

  external ffi.Pointer<
    ffi.NativeFunction<
      ffi.Pointer<objc.CFString> Function(ffi.Pointer<ffi.Void> value)
    >
  >
  copyDescription;

  external ffi.Pointer<
    ffi.NativeFunction<
      ffi.UnsignedChar Function(
        ffi.Pointer<ffi.Void> value1,
        ffi.Pointer<ffi.Void> value2,
      )
    >
  >
  equal;

  external ffi.Pointer<
    ffi.NativeFunction<ffi.UnsignedLong Function(ffi.Pointer<ffi.Void> value)>
  >
  hash;
}

final class CFDictionaryValueCallBacks extends ffi.Struct {
  @ffi.Long()
  external int version;

  external ffi.Pointer<
    ffi.NativeFunction<
      ffi.Pointer<ffi.Void> Function(
        ffi.Pointer<__CFAllocator> allocator,
        ffi.Pointer<ffi.Void> value,
      )
    >
  >
  retain;

  external ffi.Pointer<
    ffi.NativeFunction<
      ffi.Void Function(
        ffi.Pointer<__CFAllocator> allocator,
        ffi.Pointer<ffi.Void> value,
      )
    >
  >
  release;

  external ffi.Pointer<
    ffi.NativeFunction<
      ffi.Pointer<objc.CFString> Function(ffi.Pointer<ffi.Void> value)
    >
  >
  copyDescription;

  external ffi.Pointer<
    ffi.NativeFunction<
      ffi.UnsignedChar Function(
        ffi.Pointer<ffi.Void> value1,
        ffi.Pointer<ffi.Void> value2,
      )
    >
  >
  equal;
}

final class __CFDictionary extends ffi.Opaque {}

typedef CFDictionaryRef = ffi.Pointer<__CFDictionary>;

final class __CFData extends ffi.Opaque {}

typedef CFDataRef = ffi.Pointer<__CFData>;
typedef CFMutableDataRef = ffi.Pointer<__CFData>;

final class CGImageSource extends ffi.Opaque {}

typedef CGImageSourceRef = ffi.Pointer<CGImageSource>;

final class CGContext extends ffi.Opaque {}

typedef CGContextRef = ffi.Pointer<CGContext>;

final class CGColorSpace extends ffi.Opaque {}

typedef CGColorSpaceRef = ffi.Pointer<CGColorSpace>;

final class CGImage extends ffi.Opaque {}

typedef CGImageRef = ffi.Pointer<CGImage>;

sealed class CGBitmapInfo {
  static const kCGBitmapAlphaInfoMask = 31;
  static const kCGBitmapComponentInfoMask = 3840;
  static const kCGBitmapByteOrderInfoMask = 28672;
  static const kCGBitmapPixelFormatInfoMask = 983040;
  static const kCGBitmapFloatInfoMask = 3840;
  static const kCGBitmapByteOrderMask = 28672;
  static const kCGBitmapFloatComponents = 256;
  static const kCGBitmapByteOrderDefault = 0;
  static const kCGBitmapByteOrder16Little = 4096;
  static const kCGBitmapByteOrder32Little = 8192;
  static const kCGBitmapByteOrder16Big = 12288;
  static const kCGBitmapByteOrder32Big = 16384;
}

enum CGInterpolationQuality {
  kCGInterpolationDefault(0),
  kCGInterpolationNone(1),
  kCGInterpolationLow(2),
  kCGInterpolationMedium(4),
  kCGInterpolationHigh(3);

  final int value;
  const CGInterpolationQuality(this.value);

  static CGInterpolationQuality fromValue(int value) => switch (value) {
    0 => kCGInterpolationDefault,
    1 => kCGInterpolationNone,
    2 => kCGInterpolationLow,
    4 => kCGInterpolationMedium,
    3 => kCGInterpolationHigh,
    _ => throw ArgumentError(
      'Unknown value for CGInterpolationQuality: $value',
    ),
  };
}

final class CGImageDestination extends ffi.Opaque {}

typedef CGImageDestinationRef = ffi.Pointer<CGImageDestination>;
