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 // Original code is licensed as follows: | 6 // Original code is licensed as follows: |
7 /* | 7 /* |
8 * Copyright 2009 ZXing authors | 8 * Copyright 2009 ZXing authors |
9 * | 9 * |
10 * Licensed under the Apache License, Version 2.0 (the "License"); | 10 * Licensed under the Apache License, Version 2.0 (the "License"); |
(...skipping 29 matching lines...) Expand all Loading... |
40 pImageCodec = pCodecMgr->CreateProgressiveDecoder(); | 40 pImageCodec = pCodecMgr->CreateProgressiveDecoder(); |
41 FXCODEC_STATUS status = FXCODEC_STATUS_DECODE_FINISH; | 41 FXCODEC_STATUS status = FXCODEC_STATUS_DECODE_FINISH; |
42 status = pImageCodec->LoadImageInfo(fileread, FXCODEC_IMAGE_UNKNOWN); | 42 status = pImageCodec->LoadImageInfo(fileread, FXCODEC_IMAGE_UNKNOWN); |
43 if (status != FXCODEC_STATUS_FRAME_READY) { | 43 if (status != FXCODEC_STATUS_FRAME_READY) { |
44 return NULL; | 44 return NULL; |
45 } | 45 } |
46 bitmap = FX_NEW CFX_DIBitmap; | 46 bitmap = FX_NEW CFX_DIBitmap; |
47 bitmap->Create(pImageCodec->GetWidth(), pImageCodec->GetHeight(), FXDIB_Argb
); | 47 bitmap->Create(pImageCodec->GetWidth(), pImageCodec->GetHeight(), FXDIB_Argb
); |
48 bitmap->Clear(FXARGB_MAKE(0xFF, 0xFF, 0xFF, 0xFF)); | 48 bitmap->Clear(FXARGB_MAKE(0xFF, 0xFF, 0xFF, 0xFF)); |
49 CBC_Pause pause; | 49 CBC_Pause pause; |
50 FX_INT32 frames; | 50 int32_t frames; |
51 status = pImageCodec->GetFrames(frames, &pause); | 51 status = pImageCodec->GetFrames(frames, &pause); |
52 while (status == FXCODEC_STATUS_FRAME_TOBECONTINUE) { | 52 while (status == FXCODEC_STATUS_FRAME_TOBECONTINUE) { |
53 status = pImageCodec->GetFrames(frames, &pause); | 53 status = pImageCodec->GetFrames(frames, &pause); |
54 } | 54 } |
55 if (status != FXCODEC_STATUS_DECODE_READY) { | 55 if (status != FXCODEC_STATUS_DECODE_READY) { |
56 goto except; | 56 goto except; |
57 } | 57 } |
58 status = pImageCodec->StartDecode(bitmap, | 58 status = pImageCodec->StartDecode(bitmap, |
59 0, | 59 0, |
60 0, | 60 0, |
(...skipping 37 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
98 return NULL; | 98 return NULL; |
99 } | 99 } |
100 CBC_BufferedImageLuminanceSource::CBC_BufferedImageLuminanceSource(const CFX_Wid
eString &filename): CBC_LuminanceSource(0, 0), m_filename(filename) | 100 CBC_BufferedImageLuminanceSource::CBC_BufferedImageLuminanceSource(const CFX_Wid
eString &filename): CBC_LuminanceSource(0, 0), m_filename(filename) |
101 { | 101 { |
102 m_height = 0; | 102 m_height = 0; |
103 m_width = 0; | 103 m_width = 0; |
104 m_bytesPerLine = 0; | 104 m_bytesPerLine = 0; |
105 m_top = 0; | 105 m_top = 0; |
106 m_left = 0; | 106 m_left = 0; |
107 } | 107 } |
108 void CBC_BufferedImageLuminanceSource::Init(FX_INT32 &e) | 108 void CBC_BufferedImageLuminanceSource::Init(int32_t &e) |
109 { | 109 { |
110 IFX_FileRead* fileread = FX_CreateFileRead(m_filename); | 110 IFX_FileRead* fileread = FX_CreateFileRead(m_filename); |
111 m_pBitmap = CreateDIBSource(fileread); | 111 m_pBitmap = CreateDIBSource(fileread); |
112 if (m_pBitmap == NULL) { | 112 if (m_pBitmap == NULL) { |
113 e = BCExceptionLoadFile; | 113 e = BCExceptionLoadFile; |
114 return; | 114 return; |
115 } | 115 } |
116 m_pBitmap->ConvertFormat(FXDIB_Argb); | 116 m_pBitmap->ConvertFormat(FXDIB_Argb); |
117 m_height = m_pBitmap->GetHeight(); | 117 m_height = m_pBitmap->GetHeight(); |
118 m_width = m_pBitmap->GetWidth(); | 118 m_width = m_pBitmap->GetWidth(); |
(...skipping 11 matching lines...) Expand all Loading... |
130 m_rgbData.SetSize(m_height * m_width); | 130 m_rgbData.SetSize(m_height * m_width); |
131 m_bytesPerLine = m_width * 4; | 131 m_bytesPerLine = m_width * 4; |
132 m_top = 0; | 132 m_top = 0; |
133 m_left = 0; | 133 m_left = 0; |
134 } | 134 } |
135 CBC_BufferedImageLuminanceSource::~CBC_BufferedImageLuminanceSource() | 135 CBC_BufferedImageLuminanceSource::~CBC_BufferedImageLuminanceSource() |
136 { | 136 { |
137 delete m_pBitmap; | 137 delete m_pBitmap; |
138 m_pBitmap = NULL; | 138 m_pBitmap = NULL; |
139 } | 139 } |
140 CFX_ByteArray *CBC_BufferedImageLuminanceSource::GetRow(FX_INT32 y, CFX_ByteArra
y &row, FX_INT32 &e) | 140 CFX_ByteArray *CBC_BufferedImageLuminanceSource::GetRow(int32_t y, CFX_ByteArray
&row, int32_t &e) |
141 { | 141 { |
142 if (y < 0 || y >= m_height) { | 142 if (y < 0 || y >= m_height) { |
143 e = BCExceptionRequestedRowIsOutSizeTheImage; | 143 e = BCExceptionRequestedRowIsOutSizeTheImage; |
144 return NULL; | 144 return NULL; |
145 } | 145 } |
146 FX_INT32 width = m_width; | 146 int32_t width = m_width; |
147 if(row.GetSize() == 0 || row.GetSize() < width) { | 147 if(row.GetSize() == 0 || row.GetSize() < width) { |
148 row.SetSize(width); | 148 row.SetSize(width); |
149 } | 149 } |
150 if(m_rgbData.GetSize() == 0 || m_rgbData.GetSize() < width) { | 150 if(m_rgbData.GetSize() == 0 || m_rgbData.GetSize() < width) { |
151 m_rgbData.SetSize(width); | 151 m_rgbData.SetSize(width); |
152 } | 152 } |
153 FX_INT32* rowLine = (FX_INT32*)m_pBitmap->GetScanline(y); | 153 int32_t* rowLine = (int32_t*)m_pBitmap->GetScanline(y); |
154 FX_INT32 x; | 154 int32_t x; |
155 for (x = 0; x < width; x++) { | 155 for (x = 0; x < width; x++) { |
156 FX_INT32 pixel = rowLine[x]; | 156 int32_t pixel = rowLine[x]; |
157 FX_INT32 luminance = (306 * ((pixel >> 16) & 0xFF) + | 157 int32_t luminance = (306 * ((pixel >> 16) & 0xFF) + |
158 601 * ((pixel >> 8) & 0xFF) + | 158 601 * ((pixel >> 8) & 0xFF) + |
159 117 * (pixel & 0xFF)) >> 10; | 159 117 * (pixel & 0xFF)) >> 10; |
160 row[x] = (FX_BYTE) luminance; | 160 row[x] = (uint8_t) luminance; |
161 } | 161 } |
162 return &row; | 162 return &row; |
163 } | 163 } |
164 CFX_ByteArray *CBC_BufferedImageLuminanceSource::GetMatrix() | 164 CFX_ByteArray *CBC_BufferedImageLuminanceSource::GetMatrix() |
165 { | 165 { |
166 CFX_ByteArray *matirx = FX_NEW CFX_ByteArray(); | 166 CFX_ByteArray *matirx = FX_NEW CFX_ByteArray(); |
167 matirx->SetSize(m_bytesPerLine * m_height); | 167 matirx->SetSize(m_bytesPerLine * m_height); |
168 FX_INT32 *rgb = (FX_INT32*)m_pBitmap->GetBuffer(); | 168 int32_t *rgb = (int32_t*)m_pBitmap->GetBuffer(); |
169 FX_INT32 y; | 169 int32_t y; |
170 for(y = 0; y < m_height; y++) { | 170 for(y = 0; y < m_height; y++) { |
171 FX_INT32 offset = y * m_width; | 171 int32_t offset = y * m_width; |
172 FX_INT32 x; | 172 int32_t x; |
173 for(x = 0; x < m_width; x++) { | 173 for(x = 0; x < m_width; x++) { |
174 FX_INT32 pixel = rgb[offset + x]; | 174 int32_t pixel = rgb[offset + x]; |
175 FX_INT32 luminance = (306 * ((pixel >> 16) & 0xFF) + | 175 int32_t luminance = (306 * ((pixel >> 16) & 0xFF) + |
176 601 * ((pixel >> 8) & 0xFF) + | 176 601 * ((pixel >> 8) & 0xFF) + |
177 117 * (pixel & 0xFF)) >> 10; | 177 117 * (pixel & 0xFF)) >> 10; |
178 (*matirx)[offset + x] = (FX_BYTE) luminance; | 178 (*matirx)[offset + x] = (uint8_t) luminance; |
179 } | 179 } |
180 } | 180 } |
181 return matirx; | 181 return matirx; |
182 } | 182 } |
183 FX_BOOL CBC_BufferedImageLuminanceSource::IsCropSupported() | 183 FX_BOOL CBC_BufferedImageLuminanceSource::IsCropSupported() |
184 { | 184 { |
185 return TRUE; | 185 return TRUE; |
186 } | 186 } |
187 FX_BOOL CBC_BufferedImageLuminanceSource::IsRotateSupported() | 187 FX_BOOL CBC_BufferedImageLuminanceSource::IsRotateSupported() |
188 { | 188 { |
189 return TRUE; | 189 return TRUE; |
190 } | 190 } |
191 CBC_LuminanceSource *CBC_BufferedImageLuminanceSource::Crop(FX_INT32 left, FX_IN
T32 top, FX_INT32 width, FX_INT32 height) | 191 CBC_LuminanceSource *CBC_BufferedImageLuminanceSource::Crop(int32_t left, int32_
t top, int32_t width, int32_t height) |
192 { | 192 { |
193 return NULL; | 193 return NULL; |
194 } | 194 } |
195 CBC_LuminanceSource *CBC_BufferedImageLuminanceSource::RotateCounterClockwise(FX
_INT32 &e) | 195 CBC_LuminanceSource *CBC_BufferedImageLuminanceSource::RotateCounterClockwise(in
t32_t &e) |
196 { | 196 { |
197 if (!IsRotateSupported()) { | 197 if (!IsRotateSupported()) { |
198 e = BCExceptionRotateNotSupported; | 198 e = BCExceptionRotateNotSupported; |
199 return NULL; | 199 return NULL; |
200 } | 200 } |
201 FX_INT32 sourceWidth = m_width; | 201 int32_t sourceWidth = m_width; |
202 FX_INT32 sourceHeight = m_height; | 202 int32_t sourceHeight = m_height; |
203 return NULL; | 203 return NULL; |
204 } | 204 } |
OLD | NEW |