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

Side by Side Diff: src/images/SkImageDecoder_libbmp.cpp

Issue 14363003: Updates to skimage tool to use it for testing. (Closed) Base URL: https://skia.googlecode.com/svn/trunk
Patch Set: GetFormat -> GetStreamFormat Created 7 years, 8 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 | Annotate | Revision Log
« no previous file with comments | « src/images/SkImageDecoder_FactoryRegistrar.cpp ('k') | src/images/SkImageDecoder_libgif.cpp » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 1
2 /* 2 /*
3 * Copyright 2007 The Android Open Source Project 3 * Copyright 2007 The Android Open Source Project
4 * 4 *
5 * Use of this source code is governed by a BSD-style license that can be 5 * Use of this source code is governed by a BSD-style license that can be
6 * found in the LICENSE file. 6 * found in the LICENSE file.
7 */ 7 */
8 8
9 9
10 #include "bmpdecoderhelper.h" 10 #include "bmpdecoderhelper.h"
(...skipping 16 matching lines...) Expand all
27 virtual bool onDecode(SkStream* stream, SkBitmap* bm, Mode mode) SK_OVERRIDE ; 27 virtual bool onDecode(SkStream* stream, SkBitmap* bm, Mode mode) SK_OVERRIDE ;
28 28
29 private: 29 private:
30 typedef SkImageDecoder INHERITED; 30 typedef SkImageDecoder INHERITED;
31 }; 31 };
32 32
33 /////////////////////////////////////////////////////////////////////////////// 33 ///////////////////////////////////////////////////////////////////////////////
34 DEFINE_DECODER_CREATOR(BMPImageDecoder); 34 DEFINE_DECODER_CREATOR(BMPImageDecoder);
35 /////////////////////////////////////////////////////////////////////////////// 35 ///////////////////////////////////////////////////////////////////////////////
36 36
37 static SkImageDecoder* sk_libbmp_dfactory(SkStream* stream) { 37 static bool is_bmp(SkStream* stream) {
38 static const char kBmpMagic[] = { 'B', 'M' }; 38 static const char kBmpMagic[] = { 'B', 'M' };
39 39
40 40
41 char buffer[sizeof(kBmpMagic)]; 41 char buffer[sizeof(kBmpMagic)];
42 42
43 if (stream->read(buffer, sizeof(kBmpMagic)) == sizeof(kBmpMagic) && 43 return stream->read(buffer, sizeof(kBmpMagic)) == sizeof(kBmpMagic) &&
44 !memcmp(buffer, kBmpMagic, sizeof(kBmpMagic))) { 44 !memcmp(buffer, kBmpMagic, sizeof(kBmpMagic));
45 }
46
47 static SkImageDecoder* sk_libbmp_dfactory(SkStream* stream) {
48 if (is_bmp(stream)) {
45 return SkNEW(SkBMPImageDecoder); 49 return SkNEW(SkBMPImageDecoder);
46 } 50 }
47 return NULL; 51 return NULL;
48 } 52 }
49 53
50 static SkTRegistry<SkImageDecoder*, SkStream*> gReg(sk_libbmp_dfactory); 54 static SkTRegistry<SkImageDecoder*, SkStream*> gReg(sk_libbmp_dfactory);
51 55
56 static SkImageDecoder::Format get_format_bmp(SkStream* stream) {
57 if (is_bmp(stream)) {
58 return SkImageDecoder::kBMP_Format;
59 }
60 return SkImageDecoder::kUnknown_Format;
61 }
62
63 static SkTRegistry<SkImageDecoder::Format, SkStream*> gFormatReg(get_format_bmp) ;
64
52 /////////////////////////////////////////////////////////////////////////////// 65 ///////////////////////////////////////////////////////////////////////////////
53 66
54 class SkBmpDecoderCallback : public image_codec::BmpDecoderCallback { 67 class SkBmpDecoderCallback : public image_codec::BmpDecoderCallback {
55 public: 68 public:
56 // we don't copy the bitmap, just remember the pointer 69 // we don't copy the bitmap, just remember the pointer
57 SkBmpDecoderCallback(bool justBounds) : fJustBounds(justBounds) {} 70 SkBmpDecoderCallback(bool justBounds) : fJustBounds(justBounds) {}
58 71
59 // override from BmpDecoderCallback 72 // override from BmpDecoderCallback
60 virtual uint8* SetSize(int width, int height) { 73 virtual uint8* SetSize(int width, int height) {
61 fWidth = width; 74 fWidth = width;
(...skipping 82 matching lines...) Expand 10 before | Expand all | Expand 10 after
144 const int dstHeight = sampler.scaledHeight(); 157 const int dstHeight = sampler.scaledHeight();
145 const uint8_t* srcRow = callback.rgb(); 158 const uint8_t* srcRow = callback.rgb();
146 159
147 srcRow += sampler.srcY0() * srcRowBytes; 160 srcRow += sampler.srcY0() * srcRowBytes;
148 for (int y = 0; y < dstHeight; y++) { 161 for (int y = 0; y < dstHeight; y++) {
149 sampler.next(srcRow); 162 sampler.next(srcRow);
150 srcRow += sampler.srcDY() * srcRowBytes; 163 srcRow += sampler.srcDY() * srcRowBytes;
151 } 164 }
152 return true; 165 return true;
153 } 166 }
OLDNEW
« no previous file with comments | « src/images/SkImageDecoder_FactoryRegistrar.cpp ('k') | src/images/SkImageDecoder_libgif.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698