OLD | NEW |
1 // Copyright 2014 PDFium Authors. All rights reserved. | 1 // Copyright 2014 PDFium Authors. All rights reserved. |
2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
4 | 4 |
5 // Original code copyright 2014 Foxit Software Inc. http://www.foxitsoftware.com | 5 // Original code copyright 2014 Foxit Software Inc. http://www.foxitsoftware.com |
6 | 6 |
7 #include "core/fxge/fx_dib.h" | 7 #include "core/fxge/fx_dib.h" |
8 | 8 |
9 #include <limits.h> | 9 #include <limits.h> |
10 | 10 |
(...skipping 1324 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1335 *scanline++ = bb + (fb - bb) * gray / 255; | 1335 *scanline++ = bb + (fb - bb) * gray / 255; |
1336 *scanline++ = bg + (fg - bg) * gray / 255; | 1336 *scanline++ = bg + (fg - bg) * gray / 255; |
1337 *scanline = br + (fr - br) * gray / 255; | 1337 *scanline = br + (fr - br) * gray / 255; |
1338 scanline += gap; | 1338 scanline += gap; |
1339 } | 1339 } |
1340 } | 1340 } |
1341 } | 1341 } |
1342 return true; | 1342 return true; |
1343 } | 1343 } |
1344 | 1344 |
1345 CFX_DIBitmap* CFX_DIBSource::FlipImage(bool bXFlip, bool bYFlip) const { | 1345 std::unique_ptr<CFX_DIBitmap> CFX_DIBSource::FlipImage(bool bXFlip, |
1346 CFX_DIBitmap* pFlipped = new CFX_DIBitmap; | 1346 bool bYFlip) const { |
1347 if (!pFlipped->Create(m_Width, m_Height, GetFormat())) { | 1347 auto pFlipped = pdfium::MakeUnique<CFX_DIBitmap>(); |
1348 delete pFlipped; | 1348 if (!pFlipped->Create(m_Width, m_Height, GetFormat())) |
1349 return nullptr; | 1349 return nullptr; |
1350 } | 1350 |
1351 pFlipped->SetPalette(m_pPalette.get()); | 1351 pFlipped->SetPalette(m_pPalette.get()); |
1352 uint8_t* pDestBuffer = pFlipped->GetBuffer(); | 1352 uint8_t* pDestBuffer = pFlipped->GetBuffer(); |
1353 int Bpp = m_bpp / 8; | 1353 int Bpp = m_bpp / 8; |
1354 for (int row = 0; row < m_Height; row++) { | 1354 for (int row = 0; row < m_Height; row++) { |
1355 const uint8_t* src_scan = GetScanline(row); | 1355 const uint8_t* src_scan = GetScanline(row); |
1356 uint8_t* dest_scan = | 1356 uint8_t* dest_scan = |
1357 pDestBuffer + m_Pitch * (bYFlip ? (m_Height - row - 1) : row); | 1357 pDestBuffer + m_Pitch * (bYFlip ? (m_Height - row - 1) : row); |
1358 if (!bXFlip) { | 1358 if (!bXFlip) { |
1359 FXSYS_memcpy(dest_scan, src_scan, m_Pitch); | 1359 FXSYS_memcpy(dest_scan, src_scan, m_Pitch); |
1360 continue; | 1360 continue; |
(...skipping 276 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1637 uint32_t* pSrcPalette) { | 1637 uint32_t* pSrcPalette) { |
1638 m_pBitmap = pdfium::MakeUnique<CFX_DIBitmap>(); | 1638 m_pBitmap = pdfium::MakeUnique<CFX_DIBitmap>(); |
1639 if (!m_pBitmap->Create(width, height, src_format)) { | 1639 if (!m_pBitmap->Create(width, height, src_format)) { |
1640 m_pBitmap.reset(); | 1640 m_pBitmap.reset(); |
1641 return false; | 1641 return false; |
1642 } | 1642 } |
1643 if (pSrcPalette) | 1643 if (pSrcPalette) |
1644 m_pBitmap->SetPalette(pSrcPalette); | 1644 m_pBitmap->SetPalette(pSrcPalette); |
1645 return true; | 1645 return true; |
1646 } | 1646 } |
OLD | NEW |