Skip to content

Instantly share code, notes, and snippets.

@loops
Last active December 17, 2018 07:25
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save loops/b3a9e16e2cd0d73ebf44551ce84ccb6a to your computer and use it in GitHub Desktop.
Save loops/b3a9e16e2cd0d73ebf44551ce84ccb6a to your computer and use it in GitHub Desktop.
#!/bin/env perl6
use lib 'lib';
use Graphics::TinyTIFF;
use NativeCall;
# changed your library away from blob to this:
#
# sub TinyTIFFReader_getSampleData( TinyTIFFReaderFile is rw, CArray[uint16] is rw, uint16 )
#
# Didn't change anything else. And then this worked:
my TinyTIFFReaderFile $x = TinyTIFFReader_open('test16m_imagej.tif');
my $w = TinyTIFFReader_getWidth($x);
my $h = TinyTIFFReader_getHeight($x);
my $size = $w * $h;
say "size $w x $h";
my @image := CArray[uint16].allocate($size);
say TinyTIFFReader_getSampleData($x, @image, 0);
if TinyTIFFReader_wasError($x) {
say "ERROR :(";
say TinyTIFFReader_getLastError($x);
} else {
# print "{@image[$_]} " for ^$size;
# Data for image is in @image !
}
TinyTIFFReader_close($x);
@ryn1x
Copy link

ryn1x commented Dec 17, 2018

Thanks !!!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment