"Fossies" - the Fresh Open Source Software Archive  

Source code changes of the file "src/Plugins/Pdf/PDFWriter/TIFFImageHandler.cpp" between
TeXmacs-1.99.4-src.tar.gz and TeXmacs-1.99.5-src.tar.gz

About: GNU TeXmacs is a what-you-see-is-what-you-get scientific text editor, which was both inspired by TeX and GNU Emacs.

TIFFImageHandler.cpp  (TeXmacs-1.99.4-src):TIFFImageHandler.cpp  (TeXmacs-1.99.5-src)
skipping to change at line 71 skipping to change at line 71
IN NO EVENT SHALL SAM LEFFLER OR SILICON GRAPHICS BE LIABLE FOR IN NO EVENT SHALL SAM LEFFLER OR SILICON GRAPHICS BE LIABLE FOR
ANY SPECIAL, INCIDENTAL, INDIRECT OR CONSEQUENTIAL DAMAGES OF ANY KIND, ANY SPECIAL, INCIDENTAL, INDIRECT OR CONSEQUENTIAL DAMAGES OF ANY KIND,
OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS,
WHETHER OR NOT ADVISED OF THE POSSIBILITY OF DAMAGE, AND ON ANY THEORY OF WHETHER OR NOT ADVISED OF THE POSSIBILITY OF DAMAGE, AND ON ANY THEORY OF
LIABILITY, ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE LIABILITY, ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE
OF THIS SOFTWARE. OF THIS SOFTWARE.
*/ */
#ifndef PDFHUMMUS_NO_TIFF #ifndef PDFHUMMUS_NO_TIFF
#define PDFHUMMUS_NO_TIFF
#endif
#ifndef PDFHUMMUS_NO_TIFF
#include "TIFFImageHandler.h" #include "TIFFImageHandler.h"
#include "Trace.h" #include "Trace.h"
#include "ObjectsContext.h" #include "ObjectsContext.h"
#include "DictionaryContext.h" #include "DictionaryContext.h"
#include "PDFStream.h" #include "PDFStream.h"
#include "IByteWriter.h" #include "IByteWriter.h"
#include "PDFImageXObject.h" #include "PDFImageXObject.h"
#include "DocumentContext.h" #include "DocumentContext.h"
#include "ProcsetResourcesConstants.h" #include "ProcsetResourcesConstants.h"
skipping to change at line 2587 skipping to change at line 2591
for(i=0;i<stride;i++){ for(i=0;i<stride;i++){
for(j=0;j<mT2p->tiff_samplesperpixel;j++){ for(j=0;j<mT2p->tiff_samplesperpixel;j++){
inBuffer[i*mT2p->tiff_samplesperpixel + j] = inSamplebuff er[i + j*stride]; inBuffer[i*mT2p->tiff_samplesperpixel + j] = inSamplebuff er[i + j*stride];
} }
} }
} }
tsize_t TIFFImageHandler::SampleRGBAToRGB(tdata_t inData, uint32 inSampleCount) tsize_t TIFFImageHandler::SampleRGBAToRGB(tdata_t inData, uint32 inSampleCount)
{ {
uint32 i = 0; uint32 i = 0;
uint32 sample = 0;
uint8 alpha = 0; uint8 alpha = 0;
uint8* theData = (uint8*)inData;
for (i = 0; i < inSampleCount; i++) for (i = 0; i < inSampleCount; i++)
{ {
sample=((uint32*)inData)[i]; alpha = 255 - theData[i*4+3];
alpha=(uint8)((255 - (sample & 0xff)));
((uint8 *)inData)[i * 3] = (uint8) ((sample >> 24) & 0xff) + alph theData[i*3] = theData[i*4] + alpha;
a; theData[i*3+1] = theData[i*4+1] + alpha;
((uint8 *)inData)[i * 3 + 1] = (uint8) ((sample >> 16) & 0xff) + theData[i*3+2] = theData[i*4+2] + alpha;
alpha;
((uint8 *)inData)[i * 3 + 2] = (uint8) ((sample >> 8) & 0xff) + a
lpha;
} }
return (i * 3); return (i * 3);
} }
tsize_t TIFFImageHandler::SampleRGBAAToRGB(tdata_t inData, uint32 inSampleCount) tsize_t TIFFImageHandler::SampleRGBAAToRGB(tdata_t inData, uint32 inSampleCount)
{ {
uint32 i; uint32 i;
skipping to change at line 3495 skipping to change at line 3499
DestroyConversionState(); DestroyConversionState();
if(input != NULL) if(input != NULL)
TIFFClose(input); TIFFClose(input);
return imageFormXObject; return imageFormXObject;
} }
DoubleAndDoublePair TIFFImageHandler::ReadImageDimensions(IByteReaderWithPositio n* inTIFFStream,unsigned long inImageIndex) DoubleAndDoublePair TIFFImageHandler::ReadImageDimensions(IByteReaderWithPositio n* inTIFFStream,unsigned long inImageIndex)
{ {
return ReadImageInfo(inTIFFStream,inImageIndex).dimensions;
}
TIFFImageHandler::TiffImageInfo TIFFImageHandler::ReadImageInfo(IByteReaderWithP
osition* inTIFFStream,unsigned long inImageIndex)
{
TIFF* input = NULL; TIFF* input = NULL;
DoubleAndDoublePair result(-1,-1); TiffImageInfo imageInfo;
imageInfo.dimensions.first = -1;
imageInfo.dimensions.second = -1;
imageInfo.colorComponents = 0;
EStatusCode status; EStatusCode status;
do do
{ {
TIFFSetErrorHandler(ReportError); TIFFSetErrorHandler(ReportError);
TIFFSetWarningHandler(ReportWarning); TIFFSetWarningHandler(ReportWarning);
StreamWithPos streamInfo; StreamWithPos streamInfo;
streamInfo.mStream = inTIFFStream; streamInfo.mStream = inTIFFStream;
streamInfo.mOriginalPosition = inTIFFStream->GetCurrentPosition() ; streamInfo.mOriginalPosition = inTIFFStream->GetCurrentPosition() ;
skipping to change at line 3524 skipping to change at line 3537
STATIC_tiffUnmap); STATIC_tiffUnmap);
if(!input) if(!input)
{ {
TRACE_LOG("TIFFImageHandler::ReadImageDimensions. cannot open stream for reading"); TRACE_LOG("TIFFImageHandler::ReadImageDimensions. cannot open stream for reading");
break; break;
} }
InitializeConversionState(); InitializeConversionState();
mT2p->input = input; mT2p->input = input;
mT2p->inputFilePath = ""; mT2p->inputFilePath = "";
mT2p->pdf_page = inImageIndex; mT2p->pdf_page = (tdir_t)inImageIndex;
status = ReadTopLevelTiffInformation(); status = ReadTopLevelTiffInformation();
if(status != PDFHummus::eSuccess) if(status != PDFHummus::eSuccess)
break; break;
if(mT2p->pdf_page >= mT2p->tiff_pagecount) if(mT2p->pdf_page >= mT2p->tiff_pagecount)
{ {
TRACE_LOG3( TRACE_LOG3(
"TIFFImageHandler::ReadImageDimensions, Requested tif f page %u where the tiff only has %u pages. Tiff file name - %s", "TIFFImageHandler::ReadImageDimensions, Requested tif f page %u where the tiff only has %u pages. Tiff file name - %s",
mT2p->pdf_page, mT2p->pdf_page,
mT2p->tiff_pagecount, mT2p->tiff_pagecount,
mT2p->inputFilePath.c_str()); mT2p->inputFilePath.c_str());
status = PDFHummus::eFailure; status = PDFHummus::eFailure;
break; break;
} }
status = ReadTIFFPageInformation(); status = ReadTIFFPageInformation();
if(status != PDFHummus::eSuccess) if(status != PDFHummus::eSuccess)
break; break;
result.first = mT2p->pdf_mediabox.x2 - mT2p->pdf_mediabox.x1; imageInfo.dimensions.first = mT2p->pdf_mediabox.x2 - mT2p->pdf_mediabox.
result.second = mT2p->pdf_mediabox.y2 - mT2p->pdf_mediabox.y1; x1;
imageInfo.dimensions.second = mT2p->pdf_mediabox.y2 - mT2p->pdf_mediabox
.y1;
imageInfo.colorComponents = mT2p->tiff_samplesperpixel;
}while(false); }while(false);
DestroyConversionState(); DestroyConversionState();
if(input != NULL) if(input != NULL)
TIFFClose(input); TIFFClose(input);
return result; return imageInfo;
}
unsigned long TIFFImageHandler::ReadImagePageCount(IByteReaderWithPosition* inTI
FFStream)
{
TIFF* input = NULL;
unsigned long result = 0;
EStatusCode status;
do
{
TIFFSetErrorHandler(ReportError);
TIFFSetWarningHandler(ReportWarning);
StreamWithPos streamInfo;
streamInfo.mStream = inTIFFStream;
streamInfo.mOriginalPosition = inTIFFStream->GetCurrentPosition()
;
input = TIFFClientOpen("Stream", "r", (thandle_t)&streamInfo, STA
TIC_streamRead,
STATIC_streamWrite,
STATIC_streamSeek,
STATIC_streamClose,
STATIC_tiffSize,
STATIC_tiffMap,
STATIC_tiffUnmap);
if (!input)
{
TRACE_LOG("TIFFImageHandler::ReadImagePageCount. cannot o
pen stream for reading");
break;
}
InitializeConversionState();
mT2p->input = input;
mT2p->inputFilePath = "";
status = ReadTopLevelTiffInformation();
if (status != PDFHummus::eSuccess)
break;
result = mT2p->tiff_pagecount;
} while (false);
DestroyConversionState();
if (input != NULL)
TIFFClose(input);
return result;
} }
#endif #endif
 End of changes. 9 change blocks. 
14 lines changed or deleted 78 lines changed or added

Home  |  About  |  All  |  Newest  |  Fossies Dox  |  Screenshots  |  Comments  |  Imprint  |  Privacy  |  HTTPS