mirror of
https://github.com/GoogleChromeLabs/squoosh.git
synced 2025-11-14 09:39:15 +00:00
Format C / C++ with Chromium style
This commit is contained in:
committed by
Ingvar Stepanyan
parent
de543b3206
commit
a95cb740bf
@@ -1,8 +1,8 @@
|
||||
#include <string>
|
||||
#include "emscripten/bind.h"
|
||||
#include "emscripten/val.h"
|
||||
#include "src/webp/decode.h"
|
||||
#include "src/webp/demux.h"
|
||||
#include <string>
|
||||
|
||||
using namespace emscripten;
|
||||
|
||||
@@ -11,24 +11,19 @@ int version() {
|
||||
}
|
||||
|
||||
class RawImage {
|
||||
public:
|
||||
public:
|
||||
val buffer;
|
||||
int width;
|
||||
int height;
|
||||
|
||||
RawImage(val b, int w, int h)
|
||||
: buffer(b), width(w), height(h) {}
|
||||
RawImage(val b, int w, int h) : buffer(b), width(w), height(h) {}
|
||||
};
|
||||
|
||||
uint8_t* last_result;
|
||||
RawImage decode(std::string buffer) {
|
||||
int width, height;
|
||||
last_result = WebPDecodeRGBA((const uint8_t*)buffer.c_str(), buffer.size(), &width, &height);
|
||||
return RawImage(
|
||||
val(typed_memory_view(width*height*4, last_result)),
|
||||
width,
|
||||
height
|
||||
);
|
||||
return RawImage(val(typed_memory_view(width * height * 4, last_result)), width, height);
|
||||
}
|
||||
|
||||
void free_result() {
|
||||
@@ -37,9 +32,9 @@ void free_result() {
|
||||
|
||||
EMSCRIPTEN_BINDINGS(my_module) {
|
||||
class_<RawImage>("RawImage")
|
||||
.property("buffer", &RawImage::buffer)
|
||||
.property("width", &RawImage::width)
|
||||
.property("height", &RawImage::height);
|
||||
.property("buffer", &RawImage::buffer)
|
||||
.property("width", &RawImage::width)
|
||||
.property("height", &RawImage::height);
|
||||
|
||||
function("decode", &decode);
|
||||
function("version", &version);
|
||||
|
||||
Reference in New Issue
Block a user