Cleanup the code of getBitmap
This commit is contained in:
parent
b5c19a9c6d
commit
1be253e1aa
2 changed files with 20 additions and 15 deletions
|
@ -172,6 +172,9 @@ bool ReadImageSkiaFromICO(gfx::ImageSkia* image, HICON icon) {
|
|||
}
|
||||
#endif
|
||||
|
||||
void Noop(char*, void*) {
|
||||
}
|
||||
|
||||
} // namespace
|
||||
|
||||
NativeImage::NativeImage(v8::Isolate* isolate, const gfx::Image& image)
|
||||
|
@ -228,18 +231,6 @@ v8::Local<v8::Value> NativeImage::ToBitmap(v8::Isolate* isolate) {
|
|||
bitmap->getSafeSize()).ToLocalChecked();
|
||||
}
|
||||
|
||||
void noop(char*, void*) {}
|
||||
|
||||
v8::Local<v8::Value> NativeImage::GetBitmap(v8::Isolate* isolate) {
|
||||
const SkBitmap* bitmap = image_.ToSkBitmap();
|
||||
SkPixelRef* ref = bitmap->pixelRef();
|
||||
return node::Buffer::New(isolate,
|
||||
reinterpret_cast<char*>(ref->pixels()),
|
||||
bitmap->getSafeSize(),
|
||||
&noop,
|
||||
nullptr).ToLocalChecked();
|
||||
}
|
||||
|
||||
v8::Local<v8::Value> NativeImage::ToJPEG(v8::Isolate* isolate, int quality) {
|
||||
std::vector<unsigned char> output;
|
||||
gfx::JPEG1xEncodedDataFromImage(image_, quality, &output);
|
||||
|
@ -258,6 +249,16 @@ std::string NativeImage::ToDataURL() {
|
|||
return data_url;
|
||||
}
|
||||
|
||||
v8::Local<v8::Value> NativeImage::GetBitmap(v8::Isolate* isolate) {
|
||||
const SkBitmap* bitmap = image_.ToSkBitmap();
|
||||
SkPixelRef* ref = bitmap->pixelRef();
|
||||
return node::Buffer::New(isolate,
|
||||
reinterpret_cast<char*>(ref->pixels()),
|
||||
bitmap->getSafeSize(),
|
||||
&Noop,
|
||||
nullptr).ToLocalChecked();
|
||||
}
|
||||
|
||||
v8::Local<v8::Value> NativeImage::GetNativeHandle(v8::Isolate* isolate,
|
||||
mate::Arguments* args) {
|
||||
#if defined(OS_MACOSX)
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue