Skip to content

Commit 44d5625

Browse files
xVan TuringxVan Turing
authored andcommitted
* add max_sub option
* update test code and perf * update preview image
1 parent 320b4f3 commit 44d5625

20 files changed

+201
-168
lines changed

.vscode/c_cpp_properties.json

Lines changed: 0 additions & 25 deletions
This file was deleted.

CMakeLists.txt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
cmake_minimum_required(VERSION 2.8)
2-
2+
set(CMAKE_EXPORT_COMPILE_COMMANDS ON)
33
set(CMAKE_POSITION_INDEPENDENT_CODE ON)
44

55
project(cquant)

README.md

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -3,9 +3,8 @@
33
[![Build Status](https://travis-ci.org/xVanTuring/cquant.svg?branch=master)](https://travis-ci.org/xVanTuring/cquant)
44
## View Latest Doc on [Github](https://github.com/xVanTuring/cquant)
55
## Preview
6-
<!-- ![Ori]() -->
7-
<img src="./img/3.jpg" width="700px" style="margin:0 auto; display:block">
8-
<img src="./img/result.png" width="500px" style="margin:0 auto; display:block">
6+
![Screenshot from 2019-02-09 15-16-53.png](https://i.loli.net/2019/02/09/5c5e7e7b2d278.png)
7+
![Screenshot from 2019-02-09 15-16-32.png](https://i.loli.net/2019/02/09/5c5e7e7b42cd2.png)
98

109
## Usage
1110
> Current Supported Prebuild binary version: Node 6 | 8 | 10 | 11 \

TODO.md

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
1-
0. add test
2-
1. add para for subsampling
1+
0. ~~add test~~
2+
1. ~~add para for subsampling~~
33
2. use typescript wrapper
4-
3. add travis-ci
4+
3. ~~add travis-ci~~
55
4. remove rgba or not

compile_commands.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
./build/compile_commands.json

cquant.js

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,14 @@
11
const addon = require('bindings')('cquant')
2-
function paletteAsync (buffer, depth, maxColor = 5, callback = null) {
2+
function paletteAsync(buffer, depth, maxColor = 5, maxSub = 0, callback = null) {
33
if (callback == null) {
44
if (depth !== 3 && depth !== 4) {
5-
return Promise.reject(new Error('Wrong Depth'));
5+
return Promise.reject(new Error('Wrong depth!'));
66
}
77
if (maxColor <= 1 || maxColor > 256) {
8-
return Promise.reject(new Error('maxColor too small or too large'));
8+
return Promise.reject(new Error('maxColor too small or too large!'));
99
}
1010
return new Promise((res, rej) => {
11-
addon.PaletteAsync(buffer, maxColor, depth, (err, val) => {
11+
addon.PaletteAsync(buffer, maxColor, depth, maxSub, (err, val) => {
1212
if (err) {
1313
rej(err)
1414
} else {
@@ -18,14 +18,14 @@ function paletteAsync (buffer, depth, maxColor = 5, callback = null) {
1818
})
1919
} else {
2020
if (depth !== 3 && depth !== 4) {
21-
callback(new Error('Wrong Depth'));
21+
callback(new Error('Wrong depth!'));
2222
return;
2323
}
2424
if (maxColor <= 1 || maxColor > 256) {
25-
callback(new Error('maxColor too small or too large'))
25+
callback(new Error('maxColor too small or too large!'))
2626
return
2727
}
28-
addon.PaletteAsync(buffer, maxColor, depth, callback)
28+
addon.PaletteAsync(buffer, maxColor, depth, maxSub, callback)
2929
}
3030
}
3131
module.exports = {
File renamed without changes.

img/large.1.jpg.scaled.html

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
2+
<style>
3+
.color {
4+
width: 100px;
5+
height: 100px;
6+
float: left;
7+
}
8+
img{
9+
width: 500px;
10+
display: block;
11+
}
12+
</style>
13+
<img src="large.1.jpg"/><div class="color" style="background-color:rgb(75,84,81)">
14+
15+
</div> <div class="color" style="background-color:rgb(223,208,201)">
16+
17+
</div> <div class="color" style="background-color:rgb(155,152,153)">
18+
19+
</div> <div class="color" style="background-color:rgb(174,182,188)">
20+
21+
</div> <div class="color" style="background-color:rgb(172,180,177)">
22+
23+
</div>
File renamed without changes.

img/large.1.png.full.html

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
2+
<style>
3+
.color {
4+
width: 100px;
5+
height: 100px;
6+
float: left;
7+
}
8+
img{
9+
width: 500px;
10+
display: block;
11+
}
12+
</style>
13+
<img src="large.1.png"/><div class="color" style="background-color:rgb(76,84,81)">
14+
15+
</div> <div class="color" style="background-color:rgb(223,208,201)">
16+
17+
</div> <div class="color" style="background-color:rgb(154,151,151)">
18+
19+
</div> <div class="color" style="background-color:rgb(170,175,182)">
20+
21+
</div> <div class="color" style="background-color:rgb(177,188,188)">
22+
23+
</div>

0 commit comments

Comments
 (0)