C/C++ : LibTiff Tutorial
C/C++ : LibTiff Tutorial
Libtiff is a library for reading and writing Tagged Image File Format (abbreviated TIFF) files. The set also contains command line tools for processing TIFFs. It is distributed in source code and can be found as binary builds for all kinds of platforms. The libtiff software was written by Sam Leffler while working for Silicon Graphics (wikipedia).
We can use this libtiff library in Windows and Linux (I am not yet try this libtiff library in other system operation like MAC). You can download the Windows version in this address : http://gnuwin32.sourceforge.net/packages/tiff.htm.
I am interested using this libtiff library to reading my tiff image and show the output in RGBA format. This is a simple code how to print RGBA value from tiff image using libtiff library:
/*
* readtiff.c
*
* Created on: Jun 4, 2012
* Author: toto
*/
#include <stdio.h>
#include <tiffio.h>
#include <stdlib.h>
int main(int argc, char **argv)
{
TIFF *image;
uint32 width, height;
int r1,c1, t1, imagesize;
int nsamples;
unsigned char *scanline=NULL;
uint16 BitsPerSample; // normally 8 for grayscale image
uint16 SamplesPerPixel; // normally 1 for grayscale image
uint16 i;
// Open the TIFF image
if((image = TIFFOpen(argv[1], "r")) == NULL){
fprintf(stderr, "Could not open incoming image\n");
exit(42);
}
// Find the width and height of the image
TIFFGetField(image, TIFFTAG_IMAGEWIDTH, &width);
TIFFGetField(image, TIFFTAG_IMAGELENGTH, &height);
TIFFGetField(image, TIFFTAG_BITSPERSAMPLE, &BitsPerSample);
TIFFGetField(image, TIFFTAG_SAMPLESPERPIXEL, &SamplesPerPixel);
imagesize = height * width + 1; //get image size
//allocate memory for reading tif image
scanline = (unsigned char *)_TIFFmalloc(SamplesPerPixel*width);
if (scanline == NULL){
fprintf (stderr,"Could not allocate memory!\n");
exit(0);
}
fprintf(stderr,"W=%i H=%i BitsPerSample=%i SamplesPerPixel=%i\n", width, height,BitsPerSample,SamplesPerPixel);
for (r1 = 0; r1 < height; r1++)
{
TIFFReadScanline(image, scanline, r1, 0);
for (c1 = 0; c1 < width; c1++)
{
t1 = c1*SamplesPerPixel;
for(i=0; i<SamplesPerPixel; i++)
printf("%u \t", *(scanline + t1+i));
printf("\n");
}
}
_TIFFfree(scanline); //free allocate memory
TIFFClose(image);
}
Compile this C/C++ : LibTiff Tutorial with command :
gcc readtiff.c -ltiff -o readtiff
You can running this C/C++ : LibTiff Tutorial with command :
./readtiff sampletif.tiff > output.txt
We can plot see or plot this tiff RGBA value from the output.txt file.
Source : http://en.wikipedia.org/wiki/Libtiff http://gnuwin32.sourceforge.net/packages/tiff.htm
I don’t think the title of your article matches the content lol. Just kidding, mainly because I had some doubts after reading the article.
Thank you for your sharing. I am worried that I lack creative ideas. It is your article that makes me full of hope. Thank you. But, I have a question, can you help me?
I don’t think the title of your article matches the content lol. Just kidding, mainly because I had some doubts after reading the article. https://accounts.binance.bh/register/person?ref=JW3W4Y3A
The live dealer section is absolutely top notch with real hosts chatting naturally between rounds. Card games run without a single glitch and the betting limits are very flexible for both casual punters and high rollers. I really enjoy how transparent the game history tracking is so you can always review your past rounds. A solid pick for anyone who values fairness and smooth gameplay. vnvz99com
Living in Nigeria makes it easy to find betting sites but finding one that actually pays out on time is rare. This one stands out because the sports market is huge and the live streaming feature works flawlessly during big matches. I placed a few accumulators last weekend and the settlement was automatic within minutes. The interface is clean and the odds are always updated quickly without any glitches. Check out sportsbetonline
Been using this site for a few weeks now and I must say the updates keep getting better. Love how easy it is to track my matches and cash out whenever I want. Feels like a trustworthy spot to place my daily wagers. bengoplus
Can you be more specific about the content of your article? After reading it, I still have some doubts. Hope you can help me.
Your point of view caught my eye and was very interesting. Thanks. I have a question for you. https://www.binance.com/register?ref=IHJUI7TF
I don’t think the title of your article matches the content lol. Just kidding, mainly because I had some doubts after reading the article.
[9420]Jeetbuzz Official Login | সেরা অনলাইন ক্যাসিনো বোনাস ও অ্যাপ,jeetbuzz অ্যাপ ডাউনলোড করে উপভোগ করুন সেরা স্লট গেম এবং দ্রুত টাকা উত্তোলনের সুবিধা। আজই লগইন করে আপনার বোনাস সংগ্রহ করুন। visit: jeetbuzz
If you are looking for a reliable slot site, this is it. The login is fast and the game variety is impressive. I’m really enjoying the experience so far at gamezoneslotslogin
The app is lightweight and doesn’t crash, which is exactly what I need. The login is seamless every time. Love using 95jiliapplogin.