7111d463ce
This reverts commit 9a90bd16dc6756395c422adf0f24560d033ed9ea. BUG=skia: R=bsalomon@google.com Review URL: https://codereview.chromium.org/211293002 git-svn-id: http://skia.googlecode.com/svn/trunk@13939 2bbb7eff-a529-9590-31e7-b0007b416f81
33 lines
994 B
C++
33 lines
994 B
C++
#include "sk_tool_utils.h"
|
|
|
|
namespace sk_tool_utils {
|
|
|
|
const char* colortype_name(SkColorType ct) {
|
|
switch (ct) {
|
|
case kUnknown_SkColorType: return "Unknown";
|
|
case kAlpha_8_SkColorType: return "Alpha_8";
|
|
case kIndex_8_SkColorType: return "Index_8";
|
|
case kARGB_4444_SkColorType: return "ARGB_4444";
|
|
case kRGB_565_SkColorType: return "RGB_565";
|
|
case kRGBA_8888_SkColorType: return "RGBA_8888";
|
|
case kBGRA_8888_SkColorType: return "BGRA_8888";
|
|
default:
|
|
SkASSERT(false);
|
|
return "unexpected colortype";
|
|
}
|
|
}
|
|
|
|
void write_pixels(SkCanvas* canvas, const SkBitmap& bitmap, int x, int y,
|
|
SkColorType colorType, SkAlphaType alphaType) {
|
|
SkBitmap tmp(bitmap);
|
|
tmp.lockPixels();
|
|
|
|
SkImageInfo info = tmp.info();
|
|
info.fColorType = colorType;
|
|
info.fAlphaType = alphaType;
|
|
|
|
canvas->writePixels(info, tmp.getPixels(), tmp.rowBytes(), x, y);
|
|
}
|
|
|
|
}
|