summaryrefslogtreecommitdiff
path: root/fpdfsdk/fpdfattachment.cpp
diff options
context:
space:
mode:
authorJane Liu <janeliulwq@google.com>2017-08-03 16:33:40 -0400
committerChromium commit bot <commit-bot@chromium.org>2017-08-03 21:20:23 +0000
commit548334e57cae1039824d3db97bab5348fbe674e2 (patch)
tree5c547cc35c48fe5703fde77afd208f1bd1d01029 /fpdfsdk/fpdfattachment.cpp
parent6a5b7872c838ba9e24ea6e1f9a306bb95a80ae6c (diff)
downloadpdfium-548334e57cae1039824d3db97bab5348fbe674e2.tar.xz
APIs and tests for retrieving raw/decoded data from image objects
Added FPDFImageObj_GetImageDataDecoded() for retrieving the uncompressed data of an image, and FPDFImageObj_GetImageDataRaw() for retrieving the raw data of an image. * Refactored out DecodeStreamMaybeCopyAndReturnLength(), which is used to decode both attachment data and image data. * Within DecodeStreamMaybeCopyAndReturnLength(), used a different decoder function which takes care of multiple filters if exist. As a result, CPDF_StreamParser::DecodeInlineStream() which was made static previously is now moved back into namespace. Bug=pdfium:677 Change-Id: I22a22c99acaca98ef8c15f88911f2646a2c854d5 Reviewed-on: https://pdfium-review.googlesource.com/9811 Commit-Queue: Jane Liu <janeliulwq@google.com> Reviewed-by: Lei Zhang <thestig@chromium.org>
Diffstat (limited to 'fpdfsdk/fpdfattachment.cpp')
-rw-r--r--fpdfsdk/fpdfattachment.cpp24
1 files changed, 1 insertions, 23 deletions
diff --git a/fpdfsdk/fpdfattachment.cpp b/fpdfsdk/fpdfattachment.cpp
index 0cb623f81c..5bdb3bd4a2 100644
--- a/fpdfsdk/fpdfattachment.cpp
+++ b/fpdfsdk/fpdfattachment.cpp
@@ -8,7 +8,6 @@
#include <utility>
#include "core/fdrm/crypto/fx_crypt.h"
-#include "core/fpdfapi/page/cpdf_streamparser.h"
#include "core/fpdfapi/parser/cpdf_array.h"
#include "core/fpdfapi/parser/cpdf_document.h"
#include "core/fpdfapi/parser/cpdf_name.h"
@@ -273,26 +272,5 @@ FPDFAttachment_GetFile(FPDF_ATTACHMENT attachment,
if (!pFileStream)
return 0;
- uint8_t* data = pFileStream->GetRawData();
- uint32_t len = pFileStream->GetRawSize();
- CPDF_Dictionary* pFileDict = pFileStream->GetDict();
- if (!pFileDict || pFileDict->GetStringFor("Filter").IsEmpty()) {
- if (buffer && buflen >= len)
- memcpy(buffer, data, len);
-
- return len;
- }
-
- // Decode the stream if a stream filter is specified.
- uint8_t* decodedData = nullptr;
- uint32_t decodedLen = 0;
- CPDF_StreamParser::DecodeInlineStream(
- data, len, pFileDict->GetIntegerFor("Width"),
- pFileDict->GetIntegerFor("Height"), pFileDict->GetStringFor("Filter"),
- pFileDict->GetDictFor("DecodeParms"), &decodedData, &decodedLen);
- if (buffer && buflen >= decodedLen)
- memcpy(buffer, decodedData, decodedLen);
-
- FX_Free(decodedData);
- return decodedLen;
+ return DecodeStreamMaybeCopyAndReturnLength(pFileStream, buffer, buflen);
}