summaryrefslogtreecommitdiff
path: root/core/fpdfapi/page/cpdf_image.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'core/fpdfapi/page/cpdf_image.cpp')
-rw-r--r--core/fpdfapi/page/cpdf_image.cpp27
1 files changed, 16 insertions, 11 deletions
diff --git a/core/fpdfapi/page/cpdf_image.cpp b/core/fpdfapi/page/cpdf_image.cpp
index 976d6d8c47..4048c9bb4e 100644
--- a/core/fpdfapi/page/cpdf_image.cpp
+++ b/core/fpdfapi/page/cpdf_image.cpp
@@ -30,9 +30,6 @@ CPDF_Image::CPDF_Image(CPDF_Document* pDoc,
: m_pDocument(pDoc),
m_pStream(pStream.get()),
m_pOwnedStream(std::move(pStream)) {
- if (!m_pStream)
- return;
-
m_pOwnedDict =
ToDictionary(std::unique_ptr<CPDF_Object>(m_pStream->GetDict()->Clone()));
m_pDict = m_pOwnedDict.get();
@@ -42,9 +39,6 @@ CPDF_Image::CPDF_Image(CPDF_Document* pDoc,
CPDF_Image::CPDF_Image(CPDF_Document* pDoc, uint32_t dwStreamObjNum)
: m_pDocument(pDoc),
m_pStream(ToStream(pDoc->GetIndirectObject(dwStreamObjNum))) {
- if (!m_pStream)
- return;
-
m_pDict = m_pStream->GetDict();
FinishInitialization();
}
@@ -79,6 +73,14 @@ CPDF_Image* CPDF_Image::Clone() {
return pImage;
}
+void CPDF_Image::ConvertStreamToIndirectObject() {
+ if (!m_pStream->IsInline())
+ return;
+
+ ASSERT(m_pOwnedStream);
+ m_pDocument->AddIndirectObject(m_pOwnedStream.release());
+}
+
CPDF_Dictionary* CPDF_Image::InitJPEG(uint8_t* pData, uint32_t size) {
int32_t width;
int32_t height;
@@ -122,8 +124,10 @@ CPDF_Dictionary* CPDF_Image::InitJPEG(uint8_t* pData, uint32_t size) {
m_bIsMask = false;
m_Width = width;
m_Height = height;
- if (!m_pStream)
- m_pStream = new CPDF_Stream;
+ if (!m_pStream) {
+ m_pOwnedStream = pdfium::MakeUnique<CPDF_Stream>();
+ m_pStream = m_pOwnedStream.get();
+ }
return pDict;
}
@@ -334,9 +338,10 @@ void CPDF_Image::SetImage(const CFX_DIBitmap* pBitmap, int32_t iCompress) {
dest_offset = 0;
}
}
- if (!m_pStream)
- m_pStream = new CPDF_Stream;
-
+ if (!m_pStream) {
+ m_pOwnedStream = pdfium::MakeUnique<CPDF_Stream>();
+ m_pStream = m_pOwnedStream.get();
+ }
m_pStream->InitStream(dest_buf, dest_size, pDict);
m_bIsMask = pBitmap->IsAlphaMask();
m_Width = BitmapWidth;