OLD | NEW |
---|---|
(Empty) | |
1 /* | |
2 * Copyright 2015 Google Inc. | |
3 * | |
4 * Use of this source code is governed by a BSD-style license that can be | |
5 * found in the LICENSE file. | |
6 */ | |
7 | |
8 #include "SkBmpCodec.h" | |
9 #include "SkCodec.h" | |
10 #include "SkColorTable.h" | |
11 #include "SkImageInfo.h" | |
12 #include "SkMaskSwizzler.h" | |
13 #include "SkStream.h" | |
14 #include "SkSwizzler.h" | |
15 #include "SkTypes.h" | |
16 | |
17 /* | |
18 * This class implements the decoding for bmp images | |
19 */ | |
20 class SkBmpRLECodec : public SkCodec { | |
21 protected: | |
22 | |
23 /* | |
24 * Initiates the bmp decode | |
25 */ | |
26 Result onGetPixels(const SkImageInfo& dstInfo, void* dst, | |
27 size_t dstRowBytes, const Options&, SkPMColor*, | |
28 int*) override; | |
29 | |
30 SkEncodedFormat onGetEncodedFormat() const override { return kBMP_SkEncodedF ormat; } | |
31 | |
32 private: | |
33 | |
34 /* | |
35 * Creates the color table | |
36 * Sets colorCount to the new color count if it is non-NULL | |
37 */ | |
38 bool createColorTable(SkAlphaType alphaType, int* colorCount); | |
39 | |
40 /* | |
41 * Initialize swizzler | |
42 */ | |
43 bool initializeStreamBuffer(); | |
scroggo
2015/07/31 15:05:44
The comment does not match the name?
msarett
2015/08/03 22:52:35
Removed this comment
| |
44 | |
45 /* | |
46 * Set an RLE pixel using the color table | |
47 */ | |
48 void setPixel(void* dst, size_t dstRowBytes, | |
49 const SkImageInfo& dstInfo, uint32_t x, uint32_t y, | |
50 uint8_t index); | |
51 /* | |
52 * Set an RLE24 pixel from R, G, B values | |
53 */ | |
54 void setRGBPixel(void* dst, size_t dstRowBytes, | |
55 const SkImageInfo& dstInfo, uint32_t x, uint32_t y, | |
56 uint8_t red, uint8_t green, uint8_t blue); | |
57 | |
58 /* | |
59 * Performs the bitmap decoding for RLE input format | |
60 */ | |
61 Result decode(const SkImageInfo& dstInfo, void* dst, | |
62 size_t dstRowBytes, const Options& opts); | |
63 | |
64 /* | |
65 * Creates an instance of the decoder | |
66 * Called only by NewFromStream | |
67 * | |
68 * @param srcInfo contains the source width and height | |
69 * @param stream the stream of image data | |
70 * @param bitsPerPixel the number of bits used to store each pixel | |
71 * @param numColors the number of colors in the color table | |
72 * @param bytesPerColor the number of bytes in the stream used to represent | |
73 each color in the color table | |
74 * @param offset the offset of the image pixel data from the end of the | |
75 * headers | |
76 * @param rowOrder indicates whether rows are ordered top-down or bottom-up | |
77 * @param RLEBytes used only for RLE decodes, as we must decode all | |
78 * of the data at once rather than row by row | |
79 * it indicates the amount of data left in the stream | |
80 * after decoding the headers | |
81 */ | |
82 SkBmpRLECodec(const SkImageInfo& srcInfo, SkStream* stream, | |
83 uint16_t bitsPerPixel, uint32_t numColors, | |
84 uint32_t bytesPerColor, uint32_t offset, | |
85 SkBmpCodec::RowOrder rowOrder, size_t RLEBytes); | |
86 | |
87 // Fields | |
88 const uint16_t fBitsPerPixel; | |
89 SkAutoTUnref<SkColorTable> fColorTable; // owned | |
90 uint32_t fNumColors; | |
91 const uint32_t fBytesPerColor; | |
92 const uint32_t fOffset; | |
93 const SkBmpCodec::RowOrder fRowOrder; | |
94 SkAutoTDeleteArray<uint8_t> fStreamBuffer; | |
95 size_t fRLEBytes; | |
96 uint32_t fCurrRLEByte; | |
97 | |
98 friend class SkBmpCodec; | |
99 | |
100 typedef SkCodec INHERITED; | |
101 }; | |
OLD | NEW |