![]() |
#1 |
Banned
![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() Posts: 1,300
Karma: 1479
Join Date: Jul 2006
Location: Peoples Republic of Washington
Device: Reader / iPhone / Librie / Kindle
|
DJVU for iLiad
I pulled down the sources for DJVU and looked at it a bit.
Looks doable in a short time. Anyone want to get your "15 minutes of glory" and make it happen? |
![]() |
![]() |
![]() |
#2 | |
Guru
![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() Posts: 607
Karma: 2157
Join Date: Oct 2005
Device: NCR3125, Nokia 770,...
|
Quote:
|
|
![]() |
![]() |
Advert | |
|
![]() |
#3 |
Banned
![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() Posts: 1,300
Karma: 1479
Join Date: Jul 2006
Location: Peoples Republic of Washington
Device: Reader / iPhone / Librie / Kindle
|
Hmmm isn't there a DJVU viewer in Java?
![]() |
![]() |
![]() |
![]() |
#4 | |
Guru
![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() Posts: 607
Karma: 2157
Join Date: Oct 2005
Device: NCR3125, Nokia 770,...
|
Quote:
![]() |
|
![]() |
![]() |
![]() |
#5 |
Connoisseur
![]() ![]() ![]() ![]() ![]() ![]() ![]() Posts: 50
Karma: 861
Join Date: Aug 2006
Device: Zaurus C1000/iLiad/SE K750i
|
It is not difficult to write djvu viewer. I already tried, but I don't understand how to work with iliad's X server.
I can post here simple code which opens djvu and extracts a page to a pixels buffer. |
![]() |
![]() |
Advert | |
|
![]() |
#6 |
Guru
![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() Posts: 607
Karma: 2157
Join Date: Oct 2005
Device: NCR3125, Nokia 770,...
|
Hmm here could be a mixed solution, yep: instead of usinf djview (which, btw, sucks), we can have java first to extract the pages and then to show them, so we have the update. Mike, can you upload your code? I have already a old example in bash, here in http://dftuz.unizar.es/~rivero/lbdjvu.tgz
|
![]() |
![]() |
![]() |
#7 |
Connoisseur
![]() ![]() ![]() ![]() ![]() ![]() ![]() Posts: 50
Karma: 861
Join Date: Aug 2006
Device: Zaurus C1000/iLiad/SE K750i
|
Code:
#include "config.h" #include "DjVuGlobal.h" #include "ZPCodec.h" #include "GException.h" #include "GSmartPointer.h" #include "GURL.h" #include "GRect.h" #include "GPixmap.h" #include "GBitmap.h" #include "DjVuImage.h" #include "DjVuDocument.h" #include "GOS.h" #include "ByteStream.h" #include "DjVuMessage.h" #include "DjVuText.h" #include "ddjvuapi.h" GP<DjVuDocument> doc; int openFile(const char *fileName) { djvu_programname("ddjvu"); ddjvu_context_t * context = ddjvu_context_create("djview"); ddjvu_cache_set_size(context,10000000); printf("cache_size %ld\n",ddjvu_cache_get_size(context)); if (doc) doc->stop_init(); GURL gurl=GURL::Filename::UTF8(GNativeString(fileName)); doc = DjVuDocument::create_wait(gurl); /* doc = DjVuDocument::create_noinit(); if (!doc) return 1; GURL gurl=GURL::Filename::UTF8(GNativeString(fileName.latin1())); doc->start_init(gurl); */ ddjvu_context_release(context); return 1; } uint * getPageNum(int pageNum,int width,int height) { printf("step 1"); GP<DjVuImage> dimg; dimg = doc->get_page(pageNum); if (!dimg || ! dimg->wait_for_complete_decode()) { printf("error no dimg\n"); } DjVuInfo *info = dimg->get_info(); int colorp = dimg->is_legal_photo(); int blackp = dimg->is_legal_bilevel(); int compoundp = dimg->is_legal_compound(); if (!compoundp && !colorp && !blackp) { DjVuPrintErrorUTF8("%s","Warning: This is not a well formed DjVu image\n"); if (!info) printf("error\n"); } GP<GPixmap> pm; GP<GBitmap> bm; GRect renderrect(0,0,width/2,height/2); GRect fullrect(0,0,width/2,height/2); uint * buffer = new uint[width*height]; pm = dimg->get_pixmap(renderrect, fullrect); if (!pm) bm = dimg->get_bitmap(renderrect, fullrect); unsigned int buff_row = width; unsigned int* buff_ptr = new uint[width*height*10]; unsigned int px,py; unsigned int w,h; printf("here"); if (bm) { printf("BM!!!\n"); int grays = bm->get_grays(); unsigned char* row_ptr = (*bm)[bm->rows()-1]; w=bm->columns(); h=bm->rows(); for (unsigned int i=0;i<w*h;i++) { py=i/w; px=i%w; if (px==0) { row_ptr = (*bm)[bm->rows()-py-1]; buff_ptr = buffer + buff_row*py; } int v = 255 - ((row_ptr[px] * 255) / (grays-1)); buff_ptr[px] = (255<<24) | (v<<16) | (v<<8) | v; } } else if (pm) { printf("PM!!!\n"); w=pm->columns(); h=pm->rows(); GPixel* row_ptr; for (unsigned int i=0;i<w*h;i++) { py=i/w; px=i%w; if (px==0) { row_ptr=(*pm)[pm->rows()-1-py]; buff_ptr = buffer + buff_row*py; } int r = row_ptr[px].r; int g = row_ptr[px].g; int b = row_ptr[px].b; buff_ptr[px] = (255<<24) | (r<<16) | (g<<8) | b; } } return buffer; } Last edited by Mike Kostousov; 10-25-2006 at 08:09 AM. |
![]() |
![]() |
![]() |
#8 |
Banned
![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() Posts: 1,300
Karma: 1479
Join Date: Jul 2006
Location: Peoples Republic of Washington
Device: Reader / iPhone / Librie / Kindle
|
Well I know how to invalidate the e-ink display now.
So I ask: which djvu viewer is the best to start from? You all let me know and I'll go modify it to work smoothly on the iLiad and post it here. |
![]() |
![]() |
![]() |
#9 | |
Guru
![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() Posts: 607
Karma: 2157
Join Date: Oct 2005
Device: NCR3125, Nokia 770,...
|
Quote:
You only have one compiling decently, djview. But on other hand it comes with a nice packaging including command line utilities, so for the time you have compiled it, you have also got the non-gui tools, particularly ddjvu And then you find that djview depends of detecting the move of the mouse before click (no a great task for a wacom tablet, but unimplemented). And than you must rewire the keyboard to use iLiad keyboard. So perhaps it is more sensible to use you java trickies or Antartica tcl/tk (or iLiad tcl-tk?) instead of patching djview heavily. Moreover, the ddjvu in the tar.gz above is already compiled for an ARM architecture with older dinamic libraries, so I would hope it to work in the iLiad with the more recent ones. Given a page in $i, I use the following two command lines: Code:
ddjvu ebook307.djvu -page=$i -size=600x800 -format=pgm -aspect=no | pnmdepth 255 > /tmp/page0.pgm tail +4 /tmp/page0.pgm > /tmp/page1.raw ddjvu ebook307.djvu -page=$i -format=pgm -size=800x1000 -aspect=no -segment=800x600+0+400 > /tmp/page0a.pgm It is possible to rotate using pnmtools (also in the package): pnmdepth 255 /tmp/page0a.pgm | pamflip -transpose| pamflip -topbottom | tail +4 > /tmp/page1a.raw These "raw" images were still 800x600x8bits, We had a custom utility to reduce them to 2 bits (pgm4biARM), but here in the iLiad it is not needed, the Xserver will take care off, you only need some java tool to show pgm files (so not | tail+4 neither). There are some other tricks you can see in the bash script "lbdjbrowse". You have pnmpad, to put white space around a bad cropped page. pnmcrop to cut a preprocessed page, and pnmscalefixed to zoom or fit a page without cropping (fixed is because it uses not float point). Let me note also xwdtopnm. Not related to djvu, but a nice tool to view screendumps of an Xserver. Also pbmtext is a stupid utility having java running and all that, but if you need to show an ASCII message in a graphical area, it is a nice shortcut to do it from bash. Regretly I forgot to include pgm2jpg (?) or similar converters ![]() Last edited by arivero; 10-25-2006 at 02:03 PM. |
|
![]() |
![]() |
![]() |
|
![]() |
||||
Thread | Thread Starter | Forum | Replies | Last Post |
iLiad My djvu viewer | ericshliao | iRex Developer's Corner | 8 | 10-17-2010 08:28 AM |
iLiad DJVU Viewer in Java on the iLiad | scotty1024 | iRex Developer's Corner | 61 | 07-14-2010 10:36 PM |
djvu | ulgr | Calibre | 4 | 07-09-2010 05:25 AM |
Easy DJVU Reader - reading DJVU books | Rsfor | Apple Devices | 5 | 02-05-2010 08:30 PM |
DJVU? | algol | iRex | 5 | 06-09-2009 06:28 AM |