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

Side by Side Diff: samplecode/SampleTinyBitmap.cpp

Issue 169063002: use SkColorType instead of SkBitmap::Config in samplecode (Closed) Base URL: https://skia.googlecode.com/svn/trunk
Patch Set: Created 6 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 | Annotate | Revision Log
« no previous file with comments | « samplecode/SampleTiling.cpp ('k') | samplecode/SampleUnpremul.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 2011 Google Inc. 3 * Copyright 2011 Google Inc.
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 #include "SampleCode.h" 8 #include "SampleCode.h"
9 #include "SkColorPriv.h" 9 #include "SkColorPriv.h"
10 #include "SkShader.h" 10 #include "SkShader.h"
11 #include "SkView.h" 11 #include "SkView.h"
12 #include "SkCanvas.h" 12 #include "SkCanvas.h"
13 #include "SkUtils.h" 13 #include "SkUtils.h"
14 14
15 static SkBitmap make_bitmap() { 15 static SkBitmap make_bitmap() {
16 const int N = 1; 16 const int N = 1;
17 17
18 SkPMColor c[N]; 18 SkPMColor c[N];
19 for (int i = 0; i < N; i++) { 19 for (int i = 0; i < N; i++) {
20 c[i] = SkPackARGB32(0x80, 0x80, 0, 0); 20 c[i] = SkPackARGB32(0x80, 0x80, 0, 0);
21 } 21 }
22 SkColorTable* ctable = new SkColorTable(c, N); 22 SkColorTable* ctable = new SkColorTable(c, N);
23 23
24 SkBitmap bm; 24 SkBitmap bm;
25 bm.setConfig(SkBitmap::kIndex8_Config, 1, 1); 25 bm.allocPixels(SkImageInfo::Make(1, 1, kIndex_8_SkColorType,
26 bm.allocPixels(ctable); 26 kPremul_SkAlphaType),
27 NULL, ctable);
27 ctable->unref(); 28 ctable->unref();
28 29
29 bm.lockPixels(); 30 bm.lockPixels();
30 for (int y = 0; y < bm.height(); y++) { 31 for (int y = 0; y < bm.height(); y++) {
31 uint8_t* p = bm.getAddr8(0, y); 32 uint8_t* p = bm.getAddr8(0, y);
32 for (int x = 0; x < bm.width(); x++) { 33 for (int x = 0; x < bm.width(); x++) {
33 p[x] = 0; 34 p[x] = 0;
34 } 35 }
35 } 36 }
36 bm.unlockPixels(); 37 bm.unlockPixels();
(...skipping 32 matching lines...) Expand 10 before | Expand all | Expand 10 after
69 } 70 }
70 71
71 private: 72 private:
72 typedef SkView INHERITED; 73 typedef SkView INHERITED;
73 }; 74 };
74 75
75 ////////////////////////////////////////////////////////////////////////////// 76 //////////////////////////////////////////////////////////////////////////////
76 77
77 static SkView* MyFactory() { return new TinyBitmapView; } 78 static SkView* MyFactory() { return new TinyBitmapView; }
78 static SkViewRegister reg(MyFactory); 79 static SkViewRegister reg(MyFactory);
OLDNEW
« no previous file with comments | « samplecode/SampleTiling.cpp ('k') | samplecode/SampleUnpremul.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698