Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(1)

Side by Side Diff: src/codec/SkCodec_libbmp.h

Issue 947283002: Bmp Image Decoding (Closed) Base URL: https://skia.googlesource.com/skia.git@decode-leon-3
Patch Set: Tested bmp and swizzler design Created 5 years, 10 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
(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 "SkCodec.h"
9 #include "SkImageInfo.h"
10 #include "SkStream.h"
11 #include "SkTypes.h"
12
13 #ifdef SK_SUPPORT_LEGACY_IMAGE_GENERATOR_RETURN
14 #define onGetPixels onGetPixelsEnum
15 #endif
16
17 /*
18 *
19 * This class implements the decoding for bitmap images
scroggo 2015/02/25 17:22:43 nit: "bitmap" is unfortunately overloaded. I'd pre
20 *
21 */
22 class SkBmpCodec : public SkCodec {
23 public:
24
25 /*
26 *
27 * Checks the start of the stream to see if the image is a bitmap
28 *
29 */
30 static bool IsBmp(SkStream*);
31
32 /*
33 *
34 * Assumes IsBmp was called and returned true
35 * Creates a bitmap decoder
36 * Reads enough of the stream to determine the image format
37 *
38 */
39 static SkCodec* NewFromStream(SkStream*);
40
41 protected:
42
43 /*
44 *
45 * Initiates the bitmap decode
46 *
47 */
48 virtual Result onGetPixels(const SkImageInfo&, void*, size_t, SkPMColor*,
49 int*) SK_OVERRIDE;
50 private:
51
52 /*
53 *
54 * Used to define the inout format of the bitmap
55 *
56 */
57 enum BitmapInputFormat {
58 kStandard_BitmapInputFormat,
59 k4BitRLE_BitmapInputFormat,
60 k8BitRLE_BitmapInputFormat,
61 kBitMask_BitmapInputFormat,
62 kUnknown_BitmapInputFormat
63 };
64
65 /*
66 *
67 * Performs the bitmap decoding for standard and bit masks input format
68 *
69 */
70 Result decode(const SkImageInfo&, void*, uint32_t);
71
72 /*
73 *
74 * Creates an instance of the decoder
75 * Called only by NewFromStream
76 *
77 */
78 SkBmpCodec(const SkImageInfo&, SkStream*, const uint16_t,
scroggo 2015/02/25 17:22:43 Can you add parameter names? Also, please documen
79 const BitmapInputFormat, uint32_t*, SkPMColor*, const bool);
scroggo 2015/02/25 17:22:43 Typically we do not mark primitive parameters as c
80
81 /*
82 *
83 * Clean up memory used by the decoder
84 *
85 */
86 ~SkBmpCodec();
87
88 // Constants
89 static const int kBmpHeaderBytes = 14;
scroggo 2015/02/25 17:22:43 These are all details of the implementation. I thi
90 static const int kBmpOS2V1Bytes = 12;
91 static const int kBmpOS2V2Bytes = 64;
92 static const int kBmpInfoV1Bytes = 40;
93 static const int kBmpInfoV2Bytes = 52;
94 static const int kBmpInfoV3Bytes = 56;
95 static const int kBmpInfoV4Bytes = 108;
96 static const int kBmpInfoV5Bytes = 124;
97 static const int kBmpMaskBytes = 12;
98 static const int kBmpMaxDim = 1 << 16;
99
100 const uint16_t fBitsPerPixel;
101 const BitmapInputFormat fInputFormat;
102 const SkAutoTDelete<uint32_t> fBitMasks;
103 const SkAutoTDelete<SkPMColor> fColorTable;
scroggo 2015/02/25 17:22:43 I believe this is an array. SkAutoTDelete calls "d
msarett 2015/02/26 23:58:18 Oops I meant to make these SkAutoTDeleteArray.
104 const bool fInverted;
105
106 typedef SkCodec INHERITED;
107 };
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698