first commit
This commit is contained in:
commit
237c4d8c47
57
.gitignore
vendored
Normal file
57
.gitignore
vendored
Normal file
@ -0,0 +1,57 @@
|
|||||||
|
# ---> C
|
||||||
|
/imgs
|
||||||
|
/.vscode
|
||||||
|
/app
|
||||||
|
# Prerequisites
|
||||||
|
*.d
|
||||||
|
|
||||||
|
# Object files
|
||||||
|
*.o
|
||||||
|
*.ko
|
||||||
|
*.obj
|
||||||
|
*.elf
|
||||||
|
|
||||||
|
# Linker output
|
||||||
|
*.ilk
|
||||||
|
*.map
|
||||||
|
*.exp
|
||||||
|
|
||||||
|
# Precompiled Headers
|
||||||
|
*.gch
|
||||||
|
*.pch
|
||||||
|
|
||||||
|
# Libraries
|
||||||
|
*.lib
|
||||||
|
*.a
|
||||||
|
*.la
|
||||||
|
*.lo
|
||||||
|
|
||||||
|
# Shared objects (inc. Windows DLLs)
|
||||||
|
*.dll
|
||||||
|
*.so
|
||||||
|
*.so.*
|
||||||
|
*.dylib
|
||||||
|
|
||||||
|
# Executables
|
||||||
|
*.exe
|
||||||
|
*.out
|
||||||
|
*.app
|
||||||
|
*.i*86
|
||||||
|
*.x86_64
|
||||||
|
*.hex
|
||||||
|
|
||||||
|
# Debug files
|
||||||
|
*.dSYM/
|
||||||
|
*.su
|
||||||
|
*.idb
|
||||||
|
*.pdb
|
||||||
|
|
||||||
|
# Kernel Module Compile Results
|
||||||
|
*.mod*
|
||||||
|
*.cmd
|
||||||
|
.tmp_versions/
|
||||||
|
modules.order
|
||||||
|
Module.symvers
|
||||||
|
Mkfile.old
|
||||||
|
dkms.conf
|
||||||
|
|
58
tile_info.c
Normal file
58
tile_info.c
Normal file
@ -0,0 +1,58 @@
|
|||||||
|
#include <stdio.h>
|
||||||
|
#include <tiffio.h>
|
||||||
|
|
||||||
|
int main()
|
||||||
|
{
|
||||||
|
TIFF *tif = TIFFOpen("imgs/ortho.tif", "r");
|
||||||
|
if (!tif)
|
||||||
|
{
|
||||||
|
printf("Failed to open file.\n");
|
||||||
|
return 1;
|
||||||
|
}
|
||||||
|
|
||||||
|
uint32 tileWidth, tileHeight;
|
||||||
|
TIFFGetField(tif, TIFFTAG_TILEWIDTH, &tileWidth);
|
||||||
|
TIFFGetField(tif, TIFFTAG_TILELENGTH, &tileHeight);
|
||||||
|
printf("Tile size: %dx%d\n", tileWidth, tileHeight);
|
||||||
|
|
||||||
|
uint32 imageWidth, imageHeight;
|
||||||
|
TIFFGetField(tif, TIFFTAG_IMAGEWIDTH, &imageWidth);
|
||||||
|
TIFFGetField(tif, TIFFTAG_IMAGELENGTH, &imageHeight);
|
||||||
|
|
||||||
|
uint32 tilesAcross = (imageWidth + tileWidth - 1) / tileWidth;
|
||||||
|
uint32 tilesDown = (imageHeight + tileHeight - 1) / tileHeight;
|
||||||
|
uint32 totalTiles = tilesAcross * tilesDown;
|
||||||
|
printf("Tile count: %d x %d = %d\n", tilesAcross, tilesDown, totalTiles);
|
||||||
|
|
||||||
|
uint16 samplesPerPixel;
|
||||||
|
uint16 bitsPerSample;
|
||||||
|
|
||||||
|
TIFFGetField(tif, TIFFTAG_SAMPLESPERPIXEL, &samplesPerPixel);
|
||||||
|
TIFFGetField(tif, TIFFTAG_BITSPERSAMPLE, &bitsPerSample);
|
||||||
|
|
||||||
|
// 一个像素有几个通道sample,一个sample有多少位
|
||||||
|
printf("Samples per pixel: %d\n", samplesPerPixel);
|
||||||
|
printf("Bits per sample: %d\n", bitsPerSample);
|
||||||
|
|
||||||
|
uint16 sampleFormat = SAMPLEFORMAT_UINT; // 默认无符号
|
||||||
|
TIFFGetField(tif, TIFFTAG_SAMPLEFORMAT, &sampleFormat);
|
||||||
|
|
||||||
|
printf("Sample format: %d\n", sampleFormat); // 1=uint, 2=int, 3=float
|
||||||
|
|
||||||
|
tsize_t *byteCounts = NULL;
|
||||||
|
toff_t *offsets = NULL;
|
||||||
|
|
||||||
|
TIFFGetField(tif, TIFFTAG_TILEBYTECOUNTS, &byteCounts);
|
||||||
|
TIFFGetField(tif, TIFFTAG_TILEOFFSETS, &offsets);
|
||||||
|
|
||||||
|
for (uint32 i = 0; i < totalTiles; i++)
|
||||||
|
{
|
||||||
|
printf("Tile %3d: Offset = %8llu, Size = %6lu bytes\n",
|
||||||
|
i,
|
||||||
|
(unsigned long long)offsets[i],
|
||||||
|
(unsigned long)byteCounts[i]);
|
||||||
|
}
|
||||||
|
|
||||||
|
TIFFClose(tif);
|
||||||
|
return 0;
|
||||||
|
}
|
Loading…
Reference in New Issue
Block a user