mirror of
https://github.com/danbulant/node-x11
synced 2026-06-24 17:21:47 +00:00
correct RGB irder for png
This commit is contained in:
parent
16a464fc26
commit
19c3505c40
2 changed files with 77 additions and 21 deletions
|
|
@ -784,12 +784,21 @@ var FlateStream = (function() {
|
||||||
data[i++] = v;
|
data[i++] = v;
|
||||||
data[i++] = pixel[1] || 255;
|
data[i++] = pixel[1] || 255;
|
||||||
} else {
|
} else {
|
||||||
if (pixel.length == 4 && pixel[3] != 0)
|
//console.log(pixel.length);
|
||||||
console.log(pixel);
|
//if (pixel.length == 4 && pixel[3] != 0)
|
||||||
for (_k = 0, _len3 = pixel.length; _k < _len3; _k++) {
|
//console.log(pixel);
|
||||||
byte = pixel[_k];
|
//for (_k = 0, _len3 = pixel.length; _k < _len3; _k++) {
|
||||||
data[i++] = byte;
|
//for (_k = 0; _k < 4; _k++) {
|
||||||
}
|
// byte = pixel[_k];
|
||||||
|
// data[i++] = byte;
|
||||||
|
//}
|
||||||
|
var a = (256 - pixel[3])/256.;
|
||||||
|
var aa = (1.-a)*255.;
|
||||||
|
|
||||||
|
data[i++] = parseInt(pixel[2]*a + aa);
|
||||||
|
data[i++] = parseInt(pixel[1]*a + aa);
|
||||||
|
data[i++] = parseInt(pixel[0]*a + aa);
|
||||||
|
data[i++] = pixel[3];
|
||||||
if (!alpha) {
|
if (!alpha) {
|
||||||
data[i++] = 255;
|
data[i++] = 255;
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -8,9 +8,15 @@ var ButtonPress = x11.eventMask.ButtonPress;
|
||||||
var ButtonRelease = x11.eventMask.ButtonRelease;
|
var ButtonRelease = x11.eventMask.ButtonRelease;
|
||||||
var PointerMotion = x11.eventMask.PointerMotion;
|
var PointerMotion = x11.eventMask.PointerMotion;
|
||||||
|
|
||||||
|
var interv = 0;
|
||||||
|
var total_frames = 0;
|
||||||
|
var last_frames = 0;
|
||||||
|
|
||||||
x11.createClient(function(display)
|
x11.createClient(function(display)
|
||||||
{
|
{
|
||||||
var X = display.client;
|
var X = display.client;
|
||||||
|
X.InternAtom(false, 'test', function() {
|
||||||
|
});
|
||||||
X.require('big-requests', function(BigReq)
|
X.require('big-requests', function(BigReq)
|
||||||
{
|
{
|
||||||
X.require('render', function(Render) {
|
X.require('render', function(Render) {
|
||||||
|
|
@ -24,17 +30,29 @@ x11.createClient(function(display)
|
||||||
|
|
||||||
var win, picWin, piclogoi, logo;
|
var win, picWin, piclogoi, logo;
|
||||||
|
|
||||||
|
|
||||||
function showpic(path)
|
function showpic(path)
|
||||||
{
|
{
|
||||||
|
|
||||||
console.log(path);
|
console.log(path);
|
||||||
|
|
||||||
logo = require('./node-png').readPng(path);
|
logo = require('./node-png').readPng(path);
|
||||||
|
//console.log(logo);
|
||||||
|
/*
|
||||||
|
var d = logo.data; var l = logo.data.length;
|
||||||
|
for (var p=0; p < l; p+=4)
|
||||||
|
{
|
||||||
|
b = d[p];
|
||||||
|
d[p] = d[p+2];
|
||||||
|
d[p+2] = b;
|
||||||
|
}
|
||||||
|
*/
|
||||||
|
|
||||||
win = X.AllocID();
|
win = X.AllocID();
|
||||||
X.CreateWindow(
|
X.CreateWindow(
|
||||||
win, root,
|
win, root,
|
||||||
0, 0, logo.width, logo.height,
|
0, 0, logo.width, logo.height,
|
||||||
1, 1, 0,
|
1, 0, 1, 0,
|
||||||
{
|
{
|
||||||
backgroundPixel: white, eventMask: Exposure|KeyPress|ButtonPress|PointerMotion
|
backgroundPixel: white, eventMask: Exposure|KeyPress|ButtonPress|PointerMotion
|
||||||
}
|
}
|
||||||
|
|
@ -44,30 +62,54 @@ x11.createClient(function(display)
|
||||||
var gc = X.AllocID();
|
var gc = X.AllocID();
|
||||||
X.CreateGC(gc, win);
|
X.CreateGC(gc, win);
|
||||||
|
|
||||||
var pixmaplogo = X.AllocID();
|
//var pixmaplogo = X.AllocID();
|
||||||
X.CreatePixmap(pixmaplogo, win, 24, logo.width, logo.height);
|
//X.CreatePixmap(pixmaplogo, win, 32, logo.width, logo.height);
|
||||||
X.PolyFillRectangle(pixmaplogo, gc, [0, 0, 1000, 1000]);
|
//X.PolyFillRectangle(pixmaplogo, gc, [0, 0, 1000, 1000]);
|
||||||
X.PutImage(2, pixmaplogo, gc, logo.width, logo.height, 0, 0, 0, 24, logo.data);
|
//X.PutImage(2, pixmaplogo, gc, logo.width, logo.height, 0, 0, 0, 24, logo.data);
|
||||||
|
|
||||||
piclogo = X.AllocID();
|
|
||||||
Render.CreatePicture(piclogo, pixmaplogo, Render.rgb24);
|
var lastdelta = 0;
|
||||||
|
|
||||||
picWin = X.AllocID();
|
if (interv) clearInterval(interv);
|
||||||
Render.CreatePicture(picWin, win, Render.rgb24);
|
interv = setInterval(function() {
|
||||||
|
//console.log('sending!');
|
||||||
|
if (lastdelta > 100)
|
||||||
|
{
|
||||||
|
lastdelta -= 10;
|
||||||
|
} else {
|
||||||
|
var n = +new Date();
|
||||||
|
console.log(logo.data.length/(logo.width*logo.height));
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
console.log("here");
|
||||||
|
X.PutImage(2, win, gc, logo.width, logo.height, 0, 0, 0, 24, logo.data);
|
||||||
|
total_frames++;
|
||||||
|
X.GetAtomName(1, function(name) {
|
||||||
|
lastdelta = +new Date() - n;
|
||||||
|
//console.log(lastdelta);
|
||||||
|
});
|
||||||
|
}
|
||||||
|
}, 200);
|
||||||
|
//piclogo = X.AllocID();
|
||||||
|
//Render.CreatePicture(piclogo, pixmaplogo, Render.rgb24);
|
||||||
|
|
||||||
|
//picWin = X.AllocID();
|
||||||
|
//Render.CreatePicture(picWin, win, Render.rgb24);
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
var idx = 10000;
|
var idx = 10070;
|
||||||
//showpic('/Applications/iTunes.app/Contents/Resources/FolderAnimationLinenIPadLandscape.png');
|
showpic('./node-logo.png');
|
||||||
//showpic('./node-logo.png');
|
//showpic('./pnggrad8rgb.png');
|
||||||
showpic('/Applications/iPhoto.app/Contents/Resources/Themes/Assets/Mistletoe/Mistletoe-Outside-200dpi.png');
|
//var files = require('fs').readFileSync('./qqq').toString().split('\n');
|
||||||
var files = require('fs').readFileSync('./qqq').toString().split('\n');
|
|
||||||
|
|
||||||
|
|
||||||
X.on('event', function(ev) {
|
X.on('event', function(ev) {
|
||||||
if (ev.type == 12) // expose
|
if (ev.type == 12) // expose
|
||||||
{
|
{
|
||||||
Render.Composite(3, piclogo, 0, picWin, 0, 0, 0, 0, 0, 0, logo.width, logo.height);
|
//X.PutImage(2, win, gc, logo.width, logo.height, 0, 0, 0, 24, logo.data);
|
||||||
|
//Render.Composite(3, piclogo, 0, picWin, 0, 0, 0, 0, 0, 0, logo.width, logo.height);
|
||||||
}
|
}
|
||||||
if (ev.type == 2)
|
if (ev.type == 2)
|
||||||
{
|
{
|
||||||
|
|
@ -96,3 +138,8 @@ X.on('error', function(err) {
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
|
//setInterval(function() {
|
||||||
|
// console.log(total_frames - last_frames);
|
||||||
|
// last_frames = total_frames;
|
||||||
|
//}, 1000);
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue