diff --git a/apps/openstmap/custom.html b/apps/openstmap/custom.html
index 80ab29c56..6e79a6e9a 100644
--- a/apps/openstmap/custom.html
+++ b/apps/openstmap/custom.html
@@ -116,8 +116,33 @@ TODO:
if (document.getElementById("3bit").checked) {
options = {
compression:false, output:"raw",
- mode:"3bit", brightness:-64,
+ mode:"3bit",
};
+ /* If in 3 bit mode, go through all the data beforehand and
+ turn the saturation up to maximum, so when thresholded it
+ works a lot better */
+ var imageData = ctx.getImageData(0,0,width,height);
+ var rgba = imageData.data;
+ var l = width*height*4;
+ for (var i=0;i240 || d<8) { // white or grey
+ rgba[i+0]=255;
+ rgba[i+1]=255;
+ rgba[i+2]=255;
+ } else { // another colour - use max saturation
+ rgba[i+0] = (rgba[i+0]-min) * 255 / d;
+ rgba[i+1] = (rgba[i+1]-min) * 255 / d;
+ rgba[i+2] = (rgba[i+2]-min) * 255 / d;
+ }
+ }
+ ctx.putImageData(imageData,0,0);
}
console.log("Compression options", options);
var w = Math.round(width / TILESIZE);
@@ -131,7 +156,7 @@ TODO:
options.width = TILESIZE;
options.height = TILESIZE;
var imgstr = imageconverter.RGBAtoString(rgba, options);
- ctx.putImageData(imageData,x*TILESIZE, y*TILESIZE);
+ ctx.putImageData(imageData,x*TILESIZE, y*TILESIZE); // write preview
/*var compress = 'require("heatshrink").decompress('
if (!imgstr.startsWith(compress)) throw "Data in wrong format";
imgstr = imgstr.slice(compress.length,-1);*/