Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add support to TIFF extra sample. #136

Merged
merged 1 commit into from
Dec 15, 2023
Merged

Conversation

payotte
Copy link

@payotte payotte commented Dec 15, 2023

Reading a TIFF image that include a TIFF Tag extra samples.

Copy link

what-the-diff bot commented Dec 15, 2023

PR Summary

  • Introduction of New Testing File
    A fresh file named TiffImageTests.cs has been proposed, placed within the iTextSharp.LGPLv2.Core.FunctionalTests directory. This file is a collection of multiple methods designed to test aspects specific to TIFF images.

  • Addition of Sample Image
    A new sample image file sampleRGBA.tif has been added to the iTextSharp.LGPLv2.Core.FunctionalTests/iTextExamples/resources/img folder. This is used for testing image-related functionality.

  • Enhancements to TiffImage.cs
    The TiffImage.cs file located in the iTextSharp.LGPLv2.Core/iTextSharp/text/pdf/codec directory has been revised to provide better handling and processing of TIFF images:

    • Variables Initialization: A new variable named extraSamples has been declared and set to 0.
    • Condition Modification: The condition for the if statement has been adjusted. The variable extraSamples will be set to 1 if a certain tag is present in the TIFF image.
    • New Method Addition: A new function processExtraSamples designed to manage extra samples present in TIFF images has been included.
    • GetTiffImageColor Method Update: The GetTiffImageColor function now includes enhanced handling for extra samples, memory stream management for sample masks, and revised image instance creation considering extra samples.

@VahidN VahidN merged commit 7440a52 into VahidN:master Dec 15, 2023
2 checks passed
if (extraSamples > 0)
processExtraSamples(zip, mzip, outBuf, samplePerPixel, bitsPerSample, w, height);
else
zip.Write(outBuf, 0, outBuf.Length);

Check warning

Code scanning / CodeQL

Dereferenced variable may be null Warning

Variable
zip
may be null at this access because of
this
assignment.
Variable
zip
may be null at this access because of
this
assignment.
if (extraSamples > 0)
processExtraSamples(zip, mzip, outBuf, samplePerPixel, bitsPerSample, w, height);
else
zip.Write(outBuf, 0, outBuf.Length);

Check warning

Code scanning / CodeQL

Dereferenced variable may be null Warning

Variable
outBuf
may be null at this access because of
this
assignment.
Variable
outBuf
may be null at this access because of
this
assignment.
Variable
outBuf
may be null at this access because of
this
assignment.
Variable
outBuf
may be null at this access because of
this
assignment.
@@ -600,7 +612,7 @@
else
{
zip.Close();
img = Image.GetInstance(w, h, samplePerPixel, bitsPerSample, stream.ToArray());
img = Image.GetInstance(w, h, samplePerPixel - extraSamples, bitsPerSample, stream.ToArray());

Check warning

Code scanning / CodeQL

Dereferenced variable may be null Warning

Variable
stream
may be null at this access because of
this
assignment.
@@ -661,10 +673,37 @@
{
img.InitialRotation = rotation;
}

if (extraSamples > 0) {
mzip.Close();

Check warning

Code scanning / CodeQL

Dereferenced variable may be null Warning

Variable
mzip
may be null at this access because of
this
assignment.

if (extraSamples > 0) {
mzip.Close();
var mimg = Image.GetInstance(w, h, 1, bitsPerSample, mstream.ToArray());

Check warning

Code scanning / CodeQL

Dereferenced variable may be null Warning

Variable
mstream
may be null at this access because of
this
assignment.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants