const a = 0b1010, b = 0b1000;// 10, 8
(10&8) == (a&b); // true
//распаковать
let flags = a.toString(2).split('').map(Number);//Array(4) [ 1, 0, 1, 0 ]
flags[2] = 0; //изменить
//упаковать
let mask = parseInt(flags.join(''),2); // 8
// в базе хранить 8
const value = 0b1010; // 1+0+1+0
const v1 = (value & 0b1000) >> 3; // 1
const v2 = (value & 0b0100) >> 2; // 0
const v3 = (value & 0b0010) >> 1; // 1
const v4 = (value & 0b0001) >> 0; // 0
const value1 = 0b11001; // 1 + 100 (4) + 1
const mask = 0b01110 // вырезаем 2,3,4 бит
const v5 = (value1 & 0b01110) >> 1; // 100 (4)
// ...
getOrientation(file, function(orientation) {
if (orientation == 8) { // -90deg
$modal.trigger('image-action', [['left']]);
}
else if (orientation == 6) { // 90deg
$modal.trigger('image-action', [['right']]);
}
else if (orientation == 3) { // -180deg
$modal.trigger('image-action', [['left']]);
$modal.trigger('image-action', [['left']]);
}
});
// ...
function getOrientation(file, callback) {
var reader = new FileReader();
reader.onload = function(e) {
var view = new DataView(e.target.result);
if (view.getUint16(0, false) != 0xFFD8) return callback(-2);
var length = view.byteLength/2, offset = 2;
while (offset < length) {
var marker = view.getUint16(offset, false);
offset += 2;
if (marker == 0xFFE1) {
if (view.getUint32(offset += 2, false) != 0x45786966) return callback(-1);
var little = view.getUint16(offset += 6, false) == 0x4949;
offset += view.getUint32(offset + 4, little);
var tags = view.getUint16(offset, little);
offset += 2;
for (var i = 0; i < tags; i++)
if (view.getUint16(offset + (i * 12), little) == 0x0112)
return callback(view.getUint16(offset + (i * 12) + 8, little));
}
else if ((marker & 0xFF00) != 0xFF00) break;
else offset += view.getUint16(offset, false);
}
return callback(-1);
};
reader.readAsArrayBuffer(file);
}
brightness()
A CSS<percentage>
. Applies a linear multiplier to the drawing, making it appear brighter or darker. A value under 100% darkens the image, while a value over 100% brightens it. A value of 0% will create an image that is completely black, while a value of 100% leaves the input unchanged.