2003-06-30 16:44:03 +04:00
|
|
|
/*
|
|
|
|
* This file is part of NetSurf, http://netsurf.sourceforge.net/
|
|
|
|
* Licensed under the GNU General Public License,
|
|
|
|
* http://www.opensource.org/licenses/gpl-license
|
|
|
|
* Copyright 2003 James Bursa <bursa@users.sourceforge.net>
|
|
|
|
*/
|
|
|
|
|
2003-02-26 00:00:27 +03:00
|
|
|
/**
|
|
|
|
* This is just a temporary implementation using the JPEG renderer
|
|
|
|
* available in some versions of RISC OS.
|
|
|
|
*/
|
|
|
|
|
|
|
|
#include <assert.h>
|
|
|
|
#include <string.h>
|
|
|
|
#include <stdlib.h>
|
|
|
|
#include "netsurf/content/content.h"
|
|
|
|
#include "netsurf/riscos/jpeg.h"
|
|
|
|
#include "netsurf/utils/utils.h"
|
|
|
|
#include "oslib/jpeg.h"
|
|
|
|
|
|
|
|
|
|
|
|
void jpeg_create(struct content *c)
|
|
|
|
{
|
|
|
|
c->data.jpeg.data = xcalloc(0, 1);
|
|
|
|
c->data.jpeg.length = 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
void jpeg_process_data(struct content *c, char *data, unsigned long size)
|
|
|
|
{
|
|
|
|
c->data.jpeg.data = xrealloc(c->data.jpeg.data, c->data.jpeg.length + size);
|
|
|
|
memcpy(c->data.jpeg.data + c->data.jpeg.length, data, size);
|
|
|
|
c->data.jpeg.length += size;
|
2003-02-28 14:49:13 +03:00
|
|
|
c->size += size;
|
2003-02-26 00:00:27 +03:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
int jpeg_convert(struct content *c, unsigned int width, unsigned int height)
|
|
|
|
{
|
|
|
|
os_error *error;
|
|
|
|
int w, h;
|
|
|
|
error = xjpeginfo_dimensions(c->data.jpeg.data, (int) c->data.jpeg.length,
|
|
|
|
0, &w, &h, 0, 0, 0);
|
|
|
|
if (error != 0)
|
|
|
|
return 1;
|
|
|
|
c->width = w;
|
|
|
|
c->height = h;
|
2003-03-04 01:40:39 +03:00
|
|
|
c->title = xcalloc(100, 1);
|
|
|
|
sprintf(c->title, "JPEG image (%ux%u, %lu bytes)", w, h, c->data.jpeg.length);
|
2003-06-17 23:24:21 +04:00
|
|
|
c->status = CONTENT_STATUS_DONE;
|
2003-02-26 00:00:27 +03:00
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
void jpeg_revive(struct content *c, unsigned int width, unsigned int height)
|
|
|
|
{
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
void jpeg_reformat(struct content *c, unsigned int width, unsigned int height)
|
|
|
|
{
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
void jpeg_destroy(struct content *c)
|
|
|
|
{
|
|
|
|
xfree(c->data.jpeg.data);
|
2003-03-04 01:40:39 +03:00
|
|
|
xfree(c->title);
|
2003-02-26 00:00:27 +03:00
|
|
|
}
|
2003-05-10 15:15:49 +04:00
|
|
|
|
|
|
|
|
|
|
|
void jpeg_redraw(struct content *c, long x, long y,
|
2003-09-10 21:10:25 +04:00
|
|
|
unsigned long width, unsigned long height,
|
|
|
|
long clip_x0, long clip_y0, long clip_x1, long clip_y1)
|
2003-05-10 15:15:49 +04:00
|
|
|
{
|
2003-06-14 15:34:02 +04:00
|
|
|
os_factors factors;
|
|
|
|
factors.xmul = width;
|
|
|
|
factors.ymul = height;
|
|
|
|
factors.xdiv = c->width * 2;
|
|
|
|
factors.ydiv = c->height * 2;
|
|
|
|
|
2003-05-10 15:15:49 +04:00
|
|
|
xjpeg_plot_scaled((jpeg_image *) c->data.jpeg.data,
|
2003-07-18 21:07:50 +04:00
|
|
|
x, y - height,
|
2003-07-15 18:37:34 +04:00
|
|
|
&factors, (int) c->data.jpeg.length,
|
2003-05-10 15:15:49 +04:00
|
|
|
jpeg_SCALE_DITHERED);
|
|
|
|
}
|
|
|
|
|