Home » U++ Library support » Draw, Display, Images, Bitmaps, Icons » Issue loading TIFF images with plugin/TIF
Re: Issue loading TIFF images with plugin/TIF [message #59614 is a reply to message #59613] |
Wed, 15 February 2023 08:15   |
 |
mirek
Messages: 14256 Registered: November 2005
|
Ultimate Member |
|
|
Tom1 wrote on Wed, 15 February 2023 07:56Hi Mirek,
Thanks for merging. Unfortunately two necessary orientation related details were dropped while merging:
bool TIFRaster::Data::Create()
{
TIFFSetErrorHandler(NULL);
TIFFSetErrorHandlerExt(NULL);
TIFFSetWarningHandler(NULL);
TIFFSetWarningHandlerExt(NULL);
tiff = TIFFStreamOpen("tiff@" + Format64((intptr_t)this), "r", &stream);
if(!tiff)
return false;
int count = TIFFNumberOfDirectories(tiff);
if(count <= 0)
return false;
for(int i = 0; i < count; i++) {
Page& page = pages.Add();
TIFFSetDirectory(tiff, i);
TIFFGetField(tiff, TIFFTAG_IMAGEWIDTH, &page.width);
TIFFGetField(tiff, TIFFTAG_IMAGELENGTH, &page.height);
float xres, yres;
TIFFGetFieldDefaulted(tiff, TIFFTAG_XRESOLUTION, &xres);
TIFFGetFieldDefaulted(tiff, TIFFTAG_YRESOLUTION, &yres);
uint16 resunit;
TIFFGetFieldDefaulted(tiff, TIFFTAG_RESOLUTIONUNIT, &resunit);
TIFFGetFieldDefaulted(tiff, TIFFTAG_BITSPERSAMPLE, &page.bits_per_sample);
TIFFGetFieldDefaulted(tiff, TIFFTAG_SAMPLESPERPIXEL, &page.samples_per_pixel);
TIFFGetFieldDefaulted(tiff, TIFFTAG_PHOTOMETRIC, &page.photometric);
TIFFGetFieldDefaulted(tiff, TIFFTAG_ORIENTATION, &page.orientation); // << Actual orientation must be picked up if present
double dots_per_unit = (resunit == RESUNIT_INCH ? 600.0 : resunit == RESUNIT_CENTIMETER
? 600.0 / 2.54 : 0);
page.dot_size.cx = (xres ? fround(page.width * dots_per_unit / xres) : 0);
page.dot_size.cy = (yres ? fround(page.height * dots_per_unit / yres) : 0);
bool TIFRaster::Data::FetchPage()
{
if(page_error)
return false;
if(page_fetched)
return true;
cache_size = 0;
rows.Clear();
int64 bytes = row_bytes * (int64)height;
imagebuf.SetCount(size.cy * row_bytes, 0);
req_orientation = pages[page_index].orientation; // << This is needed in order to get the image in its natural orientation and avoid crash
bool res = TIFFRGBAImageGet(this, 0, width, height);
TIFFRGBAImageEnd(this);
page_open = false;
page_fetched = true;
return true;
}
Best regards,
Tom
Uhm, sorry, I was cherrypicking...
What happened to
page.orientation = 1; // Default if no tag
attr.GetAdd("tiff_orientation") = Value((int)page.orientation);
?
Mirek
[Updated on: Wed, 15 February 2023 08:16] Report message to a moderator
|
|
|
 |
|
Issue loading TIFF images with plugin/TIF
By: Tom1 on Fri, 13 January 2023 17:44
|
 |
|
Re: Issue loading TIFF images with plugin/TIF
By: Tom1 on Mon, 16 January 2023 17:42
|
 |
|
Re: Issue loading TIFF images with plugin/TIF
By: Tom1 on Tue, 17 January 2023 10:56
|
 |
|
Re: Issue loading TIFF images with plugin/TIF
By: Tom1 on Wed, 18 January 2023 11:12
|
 |
|
Re: Issue loading TIFF images with plugin/TIF
By: Tom1 on Thu, 19 January 2023 11:55
|
 |
|
Re: Issue loading TIFF images with plugin/TIF
By: Tom1 on Thu, 19 January 2023 20:29
|
 |
|
Re: Issue loading TIFF images with plugin/TIF
By: Tom1 on Tue, 24 January 2023 14:04
|
 |
|
Re: Issue loading TIFF images with plugin/TIF
By: mirek on Tue, 14 February 2023 00:46
|
 |
|
Re: Issue loading TIFF images with plugin/TIF
By: Tom1 on Tue, 14 February 2023 09:02
|
 |
|
Re: Issue loading TIFF images with plugin/TIF
By: mirek on Tue, 14 February 2023 15:28
|
 |
|
Re: Issue loading TIFF images with plugin/TIF
By: Tom1 on Tue, 14 February 2023 20:54
|
 |
|
Re: Issue loading TIFF images with plugin/TIF
By: Tom1 on Wed, 15 February 2023 07:56
|
 |
|
Re: Issue loading TIFF images with plugin/TIF
By: mirek on Wed, 15 February 2023 08:15
|
 |
|
Re: Issue loading TIFF images with plugin/TIF
By: Tom1 on Wed, 15 February 2023 08:26
|
 |
|
Re: Issue loading TIFF images with plugin/TIF
By: Tom1 on Thu, 16 February 2023 17:29
|
 |
|
Re: Issue loading TIFF images with plugin/TIF
By: mirek on Fri, 17 February 2023 11:04
|
 |
|
Re: Issue loading TIFF images with plugin/TIF
By: Tom1 on Fri, 17 February 2023 16:37
|
Goto Forum:
Current Time: Tue Apr 29 22:15:05 CEST 2025
Total time taken to generate the page: 0.01221 seconds
|