.uppdev: telpp

git-svn-id: svn://ultimatepp.org/upp/trunk@6619 f0d560ea-af0d-0410-9eb7-867de7ffcac7
This commit is contained in:
cxl 2013-11-30 08:12:01 +00:00
parent 873b94b87d
commit 7352c44ab2
5 changed files with 56 additions and 12 deletions

View file

@ -25,6 +25,17 @@ void TelDraw::Put(const Rect& r)
void TelDraw::PutImage(Point p, const Image& img, const Rect& src)
{
Put8(DRAW_IMAGE);
Put(img.GetSize());
const RGBA *end = ~img + img.GetLength();
for(const RGBA *s = ~img; s < end; s++) {
Put8(s->r);
Put8(s->g);
Put8(s->b);
Put8(s->a);
}
Put(p);
Put(src);
}
void TelDraw::PutRect(const Rect& r, Color color)

View file

@ -0,0 +1,9 @@
PREMULTIPLIED
IMAGE_ID(Test)
IMAGE_BEGIN_DATA
IMAGE_DATA(120,156,173,83,129,9,192,48,8,243,132,222,227,65,189,167,215,248,222,182,130,130,56,35,150,45,32,85,154,216,8,150)
IMAGE_DATA(6,13,106,224,10,209,69,212,157,244,65,220,78,143,206,27,136,115,50,103,229,111,99,185,122,231,236,106,78,248,89,63)
IMAGE_DATA(14,245,42,60,32,223,243,9,81,109,212,103,61,50,32,109,199,195,84,173,104,142,180,68,111,189,121,247,124,14,53,218)
IMAGE_DATA(15,113,167,205,96,119,179,240,251,101,127,178,251,211,253,69,220,191,254,97,138,27,196,239,112,64,0,0,0,0,0,0)
IMAGE_END_DATA(128, 1)

View file

@ -1,9 +1,18 @@
#include "telupp.h"
#define IMAGECLASS TeltestImg
#define IMAGEFILE <telupp/teltest.iml>
#include <Draw/iml_header.h>
#define IMAGECLASS TeltestImg
#define IMAGEFILE <telupp/teltest.iml>
#include <Draw/iml_source.h>
void DrawSomething(Draw& w)
{
w.DrawRect(0, 0, 100, 100, LtGray);
w.DrawRect(30, 30, 25, 50, Red);
w.DrawImage(10, 10, TeltestImg::Test());
}
TcpSocket server;

View file

@ -36,23 +36,24 @@ function Get16(p)
function ProcessDraw(s)
{
var x, y, cx, cy, r, g, b, imgData, i, n, px, py;
var p = new Object;
p.text = s;
p.pos = 0;
var c=document.getElementById("myCanvas");
var ctx=c.getContext("2d");
var c = document.getElementById("myCanvas");
var ctx = c.getContext("2d");
while(p.pos < p.text.length) {
Log(p.pos + ": " + p.text.charCodeAt(p.pos));
if(Char(p, 0)) {
var x = Get16(p);
var y = Get16(p);
var cx = Get16(p);
var cy = Get16(p);
var r = Get8(p);
var g = Get8(p);
var b = Get8(p);
x = Get16(p);
y = Get16(p);
cx = Get16(p);
cy = Get16(p);
r = Get8(p);
g = Get8(p);
b = Get8(p);
Log("rect: " + x + ", " + y + ", " + cx + ", " + cy);
var c = "rgb(" + r + "," + g + "," + b + ")";
ctx.fillStyle = c;
@ -60,11 +61,24 @@ function ProcessDraw(s)
ctx.fillRect(x, y, cx, cy);
}
else
p.pos++;
}
if(Char(p, 1)) {
cx = Get16(p);
cy = Get16(p);
imgData = ctx.createImageData(cx, cy);
n = icx * icy * 4;
for(i = 0; i < n; i++)
imgData.data[i] = Get8(p);
px = Get16(p);
py = Get16(p);
x = Get16(p);
y = Get16(p);
cx = Get16(p);
cy = Get16(p);
ctx.putImageData(imgData, px, py, x, y, cx, cy);
}
}
}
var req = new XMLHttpRequest();
req.open('GET', 'localhost', true);
req.overrideMimeType('text/plain; charset=x-user-defined');

View file

@ -4,6 +4,7 @@ uses
file
telupp.h,
teltest.iml,
TelDraw.cpp,
telupp.cpp,
telupp.html;