txt: ## dist_cpan-RYNIX-Graphics-TinyTIFF.md
  # NAME
  
  Graphics::TinyTIFF - Perl6 bindings to [a slightly modified] TinyTIFF
  
  # DEPENDANCIES
  
  ## Unix
  
  ```
  git clone https://github.com/ryn1x/TinyTIFF.git
  cd TinyTIFF
  mkdir build
  cd build
  cmake ..
  make
  sudo make install
  
  ```
  
  ## Windows
  
  ```
  git clone https://github.com/ryn1x/TinyTIFF.git
  cd TinyTIFF
  mkdir build
  cd build
  cmake ..
  cmake -DCMAKE_WINDOWS_EXPORT_ALL_SYMBOLS=TRUE -DBUILD_SHARED_LIBS=TRUE -G "Visual Studio 15 2017 win64" ..
  build generated ".sln" file with visual studio
  
  ```
  
  # INSTALL
  
  zef install Graphics::TinyTIFF
  
  # SYNOPSIS
  
  ```
  #!/usr/bin/env perl6
  
  use v6.c;
  use NativeCall;
  use Graphics::TinyTIFF;
  
  ########## reader ##########
  
  my $tiff = TinyTIFFReader_open('cell.tif');
  my $frames = TinyTIFFReader_countFrames($tiff);
  my $bits = TinyTIFFReader_getBitsPerSample($tiff, 0);
  my $width = TinyTIFFReader_getWidth($tiff);
  my $height = TinyTIFFReader_getHeight($tiff);
  my $description = TinyTIFFReader_getImageDescription($tiff);
  
  my $size = $width * $height;
  my $sample-data := CArray[uint8].allocate($size);
  
  TinyTIFFReader_getSampleData($tiff, $sample-data, 0);
  
  # you now have $sample-data for the current frame
  # and can manipulate it as you wish!
  
  my $format = TinyTIFFReader_getSampleFormat($tiff);
  my $samples-per-pixel = TinyTIFFReader_getSamplesPerPixel($tiff);
  my $has-next = ?TinyTIFFReader_hasNext($tiff);
  TinyTIFFReader_readNext($tiff) if $has-next;
  my $success = ?TinyTIFFReader_success($tiff);
  my $was-error = ?TinyTIFFReader_wasError($tiff);
  my $last-error = TinyTIFFReader_getLastError($tiff) if $was-error;
  TinyTIFFReader_close($tiff);
  
  ########## writer ##########
  
  my $tiff-file = TinyTIFFWriter_open('cell2.tif', $bits, $width, $height);
  my $description-size = TinyTIFFWriter_getMaxDescriptionTextSize();
  TinyTIFFWriter_writeImageVoid( $tiff-file, $sample-data);
  TinyTIFFWriter_close( $tiff-file, 'test');
  
  print qq:to/END/;
      frames            -> $frames
      bits              -> $bits
      width             -> $width
      height            -> $height
      description       -> $description
      format            -> $format
      samples per pixel -> $samples-per-pixel
      has next?         -> $has-next
      success?          -> $success
      was error?        -> $was-error
      description size  -> $description-size
      sample data       -> $sample-data[^3] ...
      END
  
  ```
  
  Output:
  
  ```
  frames            -> 1
  bits              -> 8
  width             -> 191
  height            -> 159
  description       -> image description
  format            -> 1
  samples per pixel -> 1
  has next?         -> False
  success?          -> True
  was error?        -> False
  description size  -> 1024
  sample data       -> 118 116 112 ...
  
  ```
  
  # SUBROUTINES
  
  ### sub TinyTIFFReader\_open
  
  ```
  sub TinyTIFFReader_open(
      str $filename
  ) returns NativeCall::Types::Pointer
  
  ```
  
  open tiff file for reading, returns tiff pointer
  
  ### sub TinyTIFFReader\_getSampleData
  
  ```
  sub TinyTIFFReader_getSampleData(
      NativeCall::Types::Pointer $tiff,
      NativeCall::Types::CArray $sample-data is rw,
      uint16 $sample
  ) returns int32
  
  ```
  
  read data from current frame into supplied buffer
  
  ### sub TinyTIFFReader\_close
  
  ```
  sub TinyTIFFReader_close(
      NativeCall::Types::Pointer $tiff
  ) returns Mu
  
  ```
  
  close the tiff file
  
  ### sub TinyTIFFReader\_getBitsPerSample
  
  ```
  sub TinyTIFFReader_getBitsPerSample(
      NativeCall::Types::Pointer $tiff,
      int32 $sample
  ) returns uint16
  
  ```
  
  return bits per sample of current frame
  
  ### sub TinyTIFFReader\_getWidth
  
  ```
  sub TinyTIFFReader_getWidth(
      NativeCall::Types::Pointer $tiff
  ) returns uint32
  
  ```
  
  return width of current frame
  
  ### sub TinyTIFFReader\_getHeight
  
  ```
  sub TinyTIFFReader_getHeight(
      NativeCall::Types::Pointer $tiff
  ) returns uint32
  
  ```
  
  return height of current frame
  
  ### sub TinyTIFFReader\_countFrames
  
  ```
  sub TinyTIFFReader_countFrames(
      NativeCall::Types::Pointer $tiff
  ) returns uint32
  
  ```
  
  return number of frames
  
  ### sub TinyTIFFReader\_getSampleFormat
  
  ```
  sub TinyTIFFReader_getSampleFormat(
      NativeCall::Types::Pointer $tiff
  ) returns uint16
  
  ```
  
  return sample format of current frame
  
  ### sub TinyTIFFReader\_getSamplesPerPixel
  
  ```
  sub TinyTIFFReader_getSamplesPerPixel(
      NativeCall::Types::Pointer $tiff
  ) returns uint16
  
  ```
  
  return samples per pixel of current frame
  
  ### sub TinyTIFFReader\_getImageDescription
  
  ```
  sub TinyTIFFReader_getImageDescription(
      NativeCall::Types::Pointer $tiff
  ) returns str
  
  ```
  
  return image descrition of current frame
  
  ### sub TinyTIFFReader\_hasNext
  
  ```
  sub TinyTIFFReader_hasNext(
      NativeCall::Types::Pointer $tiff
  ) returns int32
  
  ```
  
  retun non-zero if another frame exists
  
  ### sub TinyTIFFReader\_readNext
  
  ```
  sub TinyTIFFReader_readNext(
      NativeCall::Types::Pointer $tiff
  ) returns int32
  
  ```
  
  read the next frame from a multi-frame tiff
  
  ### sub TinyTIFFReader\_success
  
  ```
  sub TinyTIFFReader_success(
      NativeCall::Types::Pointer $tiff
  ) returns int32
  
  ```
  
  return non-zero if no error in last function call
  
  ### sub TinyTIFFReader\_wasError
  
  ```
  sub TinyTIFFReader_wasError(
      NativeCall::Types::Pointer $tiff
  ) returns int32
  
  ```
  
  return non-zero if error in last function call
  
  ### sub TinyTIFFReader\_getLastError
  
  ```
  sub TinyTIFFReader_getLastError(
      NativeCall::Types::Pointer $tiff
  ) returns str
  
  ```
  
  return last error message
  
  ### sub TinyTIFFWriter\_open
  
  ```
  sub TinyTIFFWriter_open(
      str $filename,
      uint16 $bits-per-sample,
      uint32 $width,
      uint32 $height
  ) returns NativeCall::Types::Pointer
  
  ```
  
  create a new tiff file, returns tiff-file pointer
  
  ### sub TinyTIFFWriter\_getMaxDescriptionTextSize
  
  ```
  sub TinyTIFFWriter_getMaxDescriptionTextSize() returns int32
  
  ```
  
  get max size for image descrition
  
  ### sub TinyTIFFWriter\_writeImageDouble
  
  ```
  sub TinyTIFFWriter_writeImageDouble(
      NativeCall::Types::Pointer $tiff-file,
      NativeCall::Types::CArray $sample-data is rw
  ) returns Mu
  
  ```
  
  writes row-major image data to a tiff file
  
  ### sub TinyTIFFWriter\_writeImageFloat
  
  ```
  sub TinyTIFFWriter_writeImageFloat(
      NativeCall::Types::Pointer $tiff-file,
      NativeCall::Types::CArray $sample-data is rw
  ) returns Mu
  
  ```
  
  writes row-major image data to a tiff file
  
  ### sub TinyTIFFWriter\_writeImageVoid
  
  ```
  sub TinyTIFFWriter_writeImageVoid(
      NativeCall::Types::Pointer $tiff-file,
      NativeCall::Types::CArray $sample-data is rw
  ) returns Mu
  
  ```
  
  writes row-major image data to a tiff file
  
  ### sub TinyTIFFWriter\_close
  
  ```
  sub TinyTIFFWriter_close(
      NativeCall::Types::Pointer $tiff-file,
      str $image-description
  ) returns Mu
  
  ```
  
  close the tiff and write image description to first frame
  
  # COPYRIGHT AND LICENSE
  
  Copyright 2018 ryn1x
  
  This library is free software; you can redistribute it and/or modify it under the Artistic License 2.0.
  