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 "../include/fsdk_define.h" | 7 #include "../include/fsdk_define.h" |
8 #include "../include/fsdk_mgr.h" | 8 #include "../include/fsdk_mgr.h" |
9 #include "../include/fpdfview.h" | 9 #include "../include/fpdfview.h" |
10 #include "../include/fsdk_rendercontext.h" | 10 #include "../include/fsdk_rendercontext.h" |
11 #include "../include/fpdf_progressive.h" | 11 #include "../include/fpdf_progressive.h" |
12 #include "../include/fpdf_ext.h" | 12 #include "../include/fpdf_ext.h" |
13 #include "../../../core/src/fxcrt/fx_safe_types.h" | 13 #include "../../../core/src/fxcrt/fx_safe_types.h" |
| 14 #include "../../third_party/base/nonstd_unique_ptr.h" |
14 #include "../../third_party/base/numerics/safe_conversions_impl.h" | 15 #include "../../third_party/base/numerics/safe_conversions_impl.h" |
15 | 16 |
16 CPDF_CustomAccess::CPDF_CustomAccess(FPDF_FILEACCESS* pFileAccess) | 17 CPDF_CustomAccess::CPDF_CustomAccess(FPDF_FILEACCESS* pFileAccess) |
17 { | 18 { |
18 if (pFileAccess) | 19 if (pFileAccess) |
19 m_FileAccess = *pFileAccess; | 20 m_FileAccess = *pFileAccess; |
20 } | 21 } |
21 | 22 |
22 FX_BOOL CPDF_CustomAccess::ReadBlock(void* buffer, FX_FILESIZE offset, size_t si
ze) | 23 FX_BOOL CPDF_CustomAccess::ReadBlock(void* buffer, FX_FILESIZE offset, size_t si
ze) |
23 { | 24 { |
(...skipping 566 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
590 | 591 |
591 FX_FLOAT device_x_f, device_y_f; | 592 FX_FLOAT device_x_f, device_y_f; |
592 page2device.Transform(((FX_FLOAT)page_x), ((FX_FLOAT)page_y), device_x_f
, device_y_f); | 593 page2device.Transform(((FX_FLOAT)page_x), ((FX_FLOAT)page_y), device_x_f
, device_y_f); |
593 | 594 |
594 *device_x = FXSYS_round(device_x_f); | 595 *device_x = FXSYS_round(device_x_f); |
595 *device_y = FXSYS_round(device_y_f); | 596 *device_y = FXSYS_round(device_y_f); |
596 } | 597 } |
597 | 598 |
598 DLLEXPORT FPDF_BITMAP STDCALL FPDFBitmap_Create(int width, int height, int alpha
) | 599 DLLEXPORT FPDF_BITMAP STDCALL FPDFBitmap_Create(int width, int height, int alpha
) |
599 { | 600 { |
600 » CFX_DIBitmap* pBitmap = new CFX_DIBitmap; | 601 nonstd::unique_ptr<CFX_DIBitmap> pBitmap(new CFX_DIBitmap); |
601 » pBitmap->Create(width, height, alpha ? FXDIB_Argb : FXDIB_Rgb32); | 602 if (!pBitmap->Create(width, height, alpha ? FXDIB_Argb : FXDIB_Rgb32)) { |
602 » return pBitmap; | 603 return NULL; |
| 604 } |
| 605 return pBitmap.release(); |
603 } | 606 } |
604 | 607 |
605 DLLEXPORT FPDF_BITMAP STDCALL FPDFBitmap_CreateEx(int width, int height, int for
mat, void* first_scan, int stride) | 608 DLLEXPORT FPDF_BITMAP STDCALL FPDFBitmap_CreateEx(int width, int height, int for
mat, void* first_scan, int stride) |
606 { | 609 { |
607 FXDIB_Format fx_format; | 610 FXDIB_Format fx_format; |
608 switch (format) { | 611 switch (format) { |
609 case FPDFBitmap_Gray: | 612 case FPDFBitmap_Gray: |
610 fx_format = FXDIB_8bppRgb; | 613 fx_format = FXDIB_8bppRgb; |
611 break; | 614 break; |
612 case FPDFBitmap_BGR: | 615 case FPDFBitmap_BGR: |
(...skipping 251 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
864 if (!buffer) { | 867 if (!buffer) { |
865 buflen = len; | 868 buflen = len; |
866 } else if (buflen >= len) { | 869 } else if (buflen >= len) { |
867 memcpy(buffer, utf16Name.c_str(), len); | 870 memcpy(buffer, utf16Name.c_str(), len); |
868 buflen = len; | 871 buflen = len; |
869 } else { | 872 } else { |
870 buflen = -1; | 873 buflen = -1; |
871 } | 874 } |
872 return (FPDF_DEST)pDestObj; | 875 return (FPDF_DEST)pDestObj; |
873 } | 876 } |
OLD | NEW |