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 "SkColorTable.h" | |
10 #include "SkImageInfo.h" | |
11 #include "SkTypes.h" | |
12 | |
13 /* | |
14 * This class implements the decoding for bmp images that use an RLE encoding | |
15 */ | |
16 class SkBmpRLECodec : public SkBmpCodec { | |
17 public: | |
18 | |
19 /* | |
20 * Creates an instance of the decoder | |
21 * Called only by SkBmpCodec::NewFromStream | |
scroggo
2015/08/04 16:16:46
Interesting that you say that, because it is a pub
msarett
2015/08/04 23:14:45
Yeah I'm pretty happy with the subclasses instead
| |
22 * | |
23 * @param srcInfo contains the source width and height | |
24 * @param stream the stream of image data | |
scroggo
2015/08/04 16:16:46
nit: encoded (image data)
msarett
2015/08/04 23:14:45
Done.
| |
25 * @param bitsPerPixel the number of bits used to store each pixel | |
26 * @param numColors the number of colors in the color table | |
27 * @param bytesPerColor the number of bytes in the stream used to represent | |
28 each color in the color table | |
29 * @param offset the offset of the image pixel data from the end of the | |
30 * headers | |
31 * @param rowOrder indicates whether rows are ordered top-down or bottom-up | |
32 * @param RLEBytes used only for RLE decodes, as we must decode all | |
scroggo
2015/08/04 16:16:46
It seems redundant to say this is used only for RL
msarett
2015/08/04 23:14:45
Done.
| |
33 * of the data at once rather than row by row | |
34 * it indicates the amount of data left in the stream | |
35 * after decoding the headers | |
36 */ | |
37 SkBmpRLECodec(const SkImageInfo& srcInfo, SkStream* stream, | |
38 uint16_t bitsPerPixel, uint32_t numColors, | |
39 uint32_t bytesPerColor, uint32_t offset, | |
40 SkBmpCodec::RowOrder rowOrder, size_t RLEBytes); | |
41 | |
42 protected: | |
43 | |
44 Result onGetPixels(const SkImageInfo& dstInfo, void* dst, | |
45 size_t dstRowBytes, const Options&, SkPMColor*, | |
46 int*) override; | |
47 | |
48 private: | |
49 | |
50 /* | |
51 * Creates the color table | |
52 * Sets colorCount to the new color count if it is non-NULL | |
53 */ | |
54 bool createColorTable(SkAlphaType alphaType, int* colorCount); | |
msarett
2015/08/03 22:52:36
Used to be in SkBmpCodec. This has been simplifie
| |
55 | |
56 bool initializeStreamBuffer(); | |
msarett
2015/08/03 22:52:36
Factored out of decodeRLE(). Will make scanline d
| |
57 | |
58 /* | |
59 * Set an RLE pixel using the color table | |
60 */ | |
61 void setPixel(void* dst, size_t dstRowBytes, | |
62 const SkImageInfo& dstInfo, uint32_t x, uint32_t y, | |
63 uint8_t index); | |
64 /* | |
65 * Set an RLE24 pixel from R, G, B values | |
66 */ | |
67 void setRGBPixel(void* dst, size_t dstRowBytes, | |
68 const SkImageInfo& dstInfo, uint32_t x, uint32_t y, | |
69 uint8_t red, uint8_t green, uint8_t blue); | |
70 | |
71 /* | |
72 * Performs the bitmap decoding for RLE input format | |
73 */ | |
74 Result decode(const SkImageInfo& dstInfo, void* dst, | |
msarett
2015/08/03 22:52:36
Used to be decodeRLE() in SkBmpCodec.
| |
75 size_t dstRowBytes, const Options& opts); | |
76 | |
77 SkAutoTUnref<SkColorTable> fColorTable; // owned | |
78 uint32_t fNumColors; | |
79 const uint32_t fBytesPerColor; | |
80 const uint32_t fOffset; | |
81 SkAutoTDeleteArray<uint8_t> fStreamBuffer; | |
82 size_t fRLEBytes; | |
83 uint32_t fCurrRLEByte; | |
84 | |
85 typedef SkBmpCodec INHERITED; | |
86 }; | |
OLD | NEW |