Initial commit of picviewer.

Conflicts:

	Makefile
	extentions.lua
	pic.c
	reader.lua
pull/2/merge
Tigran Aivazian 12 years ago committed by Qingping Hou
parent 2b185961e8
commit 503c9b077d

@ -28,6 +28,7 @@
#include "pdf.h"
#include "mupdfimg.h"
#include "djvu.h"
#include "pic.h"
#include "cre.h"
#include "einkfb.h"
#include "input.h"
@ -96,6 +97,7 @@ int main(int argc, char **argv) {
luaopen_einkfb(L);
luaopen_pdf(L);
luaopen_djvu(L);
luaopen_pic(L);
luaopen_cre(L);
luaopen_input(L);
luaopen_util(L);

26
pic.c

@ -20,7 +20,6 @@
#include <string.h>
#include <stdio.h>
#include <math.h>
#include "blitbuffer.h"
#include "drawcontext.h"
#include "pic.h"
@ -87,11 +86,6 @@ static int openDocument(lua_State *L) {
} else {
free(raw_image);
return luaL_error(L, "Unsupported image format");
}
doc->width = width;
doc->height = height;
doc->components = components;
return 1;
}
@ -171,26 +165,6 @@ static int drawPage(lua_State *L) {
scaleImage(scaled_image, page->image, img_width, img_height, img_new_width, img_new_height);
uint8_t *bbptr = bb->data;
uint8_t *pmptr = scaled_image;
bbptr += bb->pitch * y_offset;
for(y = y_offset; y < img_new_height; y++) {
for(x = x_offset/2; x < (img_new_width / 2); x++) {
int p = x*2 - x_offset;
unsigned char low = 15 - (pmptr[p + 1] >> 4);
unsigned char high = 15 - (pmptr[p] >> 4);
if (adjust_pixels)
bbptr[x] = adjusted_high[high] | adjusted_low[low];
else
bbptr[x] = (high << 4) | low;
}
if (img_new_width & 1)
bbptr[x] = 255 - (pmptr[x*2] & 0xF0);
bbptr += bb->pitch;
pmptr += img_new_width;
}
free(scaled_image);
return 0;
}

27
pic.h

@ -0,0 +1,27 @@
/*
KindlePDFViewer: JPEG Picture viewer abstraction for Lua
Copyright (C) 2012 Tigran Aivazian <tigran@bibles.org.uk>
This program is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
#ifndef _JPG_H
#define _JPG_H
#include <lua.h>
#include <lualib.h>
#include <lauxlib.h>
int luaopen_pic(lua_State *L);
#endif

@ -0,0 +1,11 @@
require "unireader"
PICViewer = UniReader:new{}
function PICViewer:open(filename)
ok, self.doc = pcall(pic.openDocument, filename)
if not ok then
return ok, self.doc
end
return ok
end

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.1 KiB

Loading…
Cancel
Save