This commit is contained in:
Haojian Wu 2015-08-04 16:50:33 +08:00 коммит произвёл Cheng Zhao
Родитель 46c7ba734b
Коммит 11ffb9dfb6
2 изменённых файлов: 9 добавлений и 8 удалений

Просмотреть файл

@ -148,17 +148,18 @@ mate::ObjectTemplateBuilder NativeImage::GetObjectTemplateBuilder(
v8::Local<v8::Value> NativeImage::ToPNG(v8::Isolate* isolate) {
scoped_refptr<base::RefCountedMemory> png = image_.As1xPNGBytes();
return node::Buffer::New(isolate,
reinterpret_cast<const char*>(png->front()),
png->size());
return node::Buffer::Copy(isolate,
reinterpret_cast<const char*>(png->front()),
static_cast<size_t>(png->size())).ToLocalChecked();
}
v8::Local<v8::Value> NativeImage::ToJPEG(v8::Isolate* isolate, int quality) {
std::vector<unsigned char> output;
gfx::JPEG1xEncodedDataFromImage(image_, quality, &output);
return node::Buffer::New(isolate,
reinterpret_cast<const char*>(&output.front()),
output.size());
return node::Buffer::Copy(
isolate,
reinterpret_cast<const char*>(&output.front()),
static_cast<size_t>(output.size())).ToLocalChecked();
}
std::string NativeImage::ToDataURL() {

Просмотреть файл

@ -125,8 +125,8 @@ void PrintPreviewMessageHandler::RunPrintToPDFCallback(
v8::Locker locker(isolate);
v8::HandleScope handle_scope(isolate);
if (data) {
v8::Local<v8::Value> buffer = node::Buffer::Use(isolate,
data, static_cast<size_t>(data_size));
v8::Local<v8::Value> buffer = node::Buffer::New(isolate,
data, static_cast<size_t>(data_size)).ToLocalChecked();
print_to_pdf_callback_map_[request_id].Run(v8::Null(isolate), buffer);
} else {
v8::Local<v8::String> error_message = v8::String::NewFromUtf8(isolate,