9fans - fans of the OS Plan 9 from Bell Labs
 help / color / mirror / Atom feed
* [9fans] page fit to window does not work on large jpegs
@ 2012-04-08 18:35 Ingo Krabbe
  2012-04-12 17:47 ` andrey mirtchovski
  2012-04-12 18:56 ` cinap_lenrek
  0 siblings, 2 replies; 16+ messages in thread
From: Ingo Krabbe @ 2012-04-08 18:35 UTC (permalink / raw)
  To: 9fans

Hey 9fans,

Today I tried to open a quite large jpeg. About 2400x1800 pixel. So first I want an overview of that image. So I choose "Fit in Window" from the page window.
All that this command does is "page: unloadimage", which was not the expected function. Actually I found no way to scale the image down and just get an overview of it.

regards, ingo
--
i don't do signatures



^ permalink raw reply	[flat|nested] 16+ messages in thread

* Re: [9fans] page fit to window does not work on large jpegs
  2012-04-08 18:35 [9fans] page fit to window does not work on large jpegs Ingo Krabbe
@ 2012-04-12 17:47 ` andrey mirtchovski
  2012-04-12 18:23   ` Ingo Krabbe
  2012-04-12 18:56 ` cinap_lenrek
  1 sibling, 1 reply; 16+ messages in thread
From: andrey mirtchovski @ 2012-04-12 17:47 UTC (permalink / raw)
  To: Fans of the OS Plan 9 from Bell Labs

change line 452 of /sys/src/cmd/page/rotate.c to
'sysfatal("unloadimage: %r");', compile and run your program again.
the code will now print what the exact error is and we can take it
from there.



^ permalink raw reply	[flat|nested] 16+ messages in thread

* Re: [9fans] page fit to window does not work on large jpegs
  2012-04-12 17:47 ` andrey mirtchovski
@ 2012-04-12 18:23   ` Ingo Krabbe
  2012-04-12 18:31     ` erik quanstrom
  0 siblings, 1 reply; 16+ messages in thread
From: Ingo Krabbe @ 2012-04-12 18:23 UTC (permalink / raw)
  To: Fans of the OS Plan 9 from Bell Labs

On Thu, Apr 12, 2012 at 11:47:49AM -0600, andrey mirtchovski wrote:
> change line 452 of /sys/src/cmd/page/rotate.c to
> 'sysfatal("unloadimage: %r");', compile and run your program again.

Yes, that was expected somehow:
page: unloadimage: unloadimage: image too wide

Maybe I will take a closer look later.


> the code will now print what the exact error is and we can take it
> from there.

--
i don't do signatures



^ permalink raw reply	[flat|nested] 16+ messages in thread

* Re: [9fans] page fit to window does not work on large jpegs
  2012-04-12 18:23   ` Ingo Krabbe
@ 2012-04-12 18:31     ` erik quanstrom
  2012-04-12 20:43       ` Ingo Krabbe
  0 siblings, 1 reply; 16+ messages in thread
From: erik quanstrom @ 2012-04-12 18:31 UTC (permalink / raw)
  To: 9fans

On Thu Apr 12 14:24:25 EDT 2012, ikrabbe.ask@gmail.com wrote:
> On Thu, Apr 12, 2012 at 11:47:49AM -0600, andrey mirtchovski wrote:
> > change line 452 of /sys/src/cmd/page/rotate.c to
> > 'sysfatal("unloadimage: %r");', compile and run your program again.
>
> Yes, that was expected somehow:
> page: unloadimage: unloadimage: image too wide
>
> Maybe I will take a closer look later.

/sys/src/libdraw/unloadimage.c:31

you could start by making that constant 12000 or some such.
that will probablly violate some other assumption, but at least
it's a start.

- erik



^ permalink raw reply	[flat|nested] 16+ messages in thread

* Re: [9fans] page fit to window does not work on large jpegs
  2012-04-08 18:35 [9fans] page fit to window does not work on large jpegs Ingo Krabbe
  2012-04-12 17:47 ` andrey mirtchovski
@ 2012-04-12 18:56 ` cinap_lenrek
  2012-04-12 20:59   ` erik quanstrom
  1 sibling, 1 reply; 16+ messages in thread
From: cinap_lenrek @ 2012-04-12 18:56 UTC (permalink / raw)
  To: 9fans

this is fixed in 9front. the problem is this:

kernel devdraw needs full draw rpc messages in every write(). but
9p has a io unit. libdraws loadimage will fill its its io buffer
with a number of scanlines and then do a rpc until the whole image
is loaded. if the size of a single scanline exceeds the buffer size,
it will fail.

our solution was to make loadimage split the scanlines in that case,
so no matter how wide the image gets, it will get loaded correctly.

also, the compressed image format has a similar limitation. we changed
writememimage to produce uncompressed images if the compressed
blocksize would exceed the buffer.

--
cinap



^ permalink raw reply	[flat|nested] 16+ messages in thread

* Re: [9fans] page fit to window does not work on large jpegs
  2012-04-12 20:59   ` erik quanstrom
@ 2012-04-12 19:20     ` cinap_lenrek
  2012-04-12 21:35       ` erik quanstrom
  0 siblings, 1 reply; 16+ messages in thread
From: cinap_lenrek @ 2012-04-12 19:20 UTC (permalink / raw)
  To: 9fans

just the very wide ones will degrade to uncompressed
format. the alternative would be changing devdraw
to accept infinitely long draw rpcs split over multiple
writes. would require changes in drawterm, inferno, 9vx
plan9... doesnt seem worth the trouble.

--
cinap



^ permalink raw reply	[flat|nested] 16+ messages in thread

* Re: [9fans] page fit to window does not work on large jpegs
  2012-04-12 18:31     ` erik quanstrom
@ 2012-04-12 20:43       ` Ingo Krabbe
  2012-04-12 20:46         ` erik quanstrom
  0 siblings, 1 reply; 16+ messages in thread
From: Ingo Krabbe @ 2012-04-12 20:43 UTC (permalink / raw)
  To: 9fans

On Thu, Apr 12, 2012 at 02:31:05PM -0400, erik quanstrom wrote:
> On Thu Apr 12 14:24:25 EDT 2012, ikrabbe.ask@gmail.com wrote:
> > On Thu, Apr 12, 2012 at 11:47:49AM -0600, andrey mirtchovski wrote:
> > > change line 452 of /sys/src/cmd/page/rotate.c to
> > > 'sysfatal("unloadimage: %r");', compile and run your program again.
> >
> > Yes, that was expected somehow:
> > page: unloadimage: unloadimage: image too wide
> >
> > Maybe I will take a closer look later.
>
> /sys/src/libdraw/unloadimage.c:31
>
> you could start by making that constant 12000 or some such.
> that will probablly violate some other assumption, but at least
> it's a start.

I assume that might be related to Displaybufsize=8000 in draw.h

>
> - erik

--
i don't do signatures



^ permalink raw reply	[flat|nested] 16+ messages in thread

* Re: [9fans] page fit to window does not work on large jpegs
  2012-04-12 20:43       ` Ingo Krabbe
@ 2012-04-12 20:46         ` erik quanstrom
  0 siblings, 0 replies; 16+ messages in thread
From: erik quanstrom @ 2012-04-12 20:46 UTC (permalink / raw)
  To: ikrabbe.ask, 9fans

> > you could start by making that constant 12000 or some such.
> > that will probablly violate some other assumption, but at least
> > it's a start.
>
> I assume that might be related to Displaybufsize=8000 in draw.h

at least on my system, that symbol is not used.

- erik



^ permalink raw reply	[flat|nested] 16+ messages in thread

* Re: [9fans] page fit to window does not work on large jpegs
  2012-04-12 18:56 ` cinap_lenrek
@ 2012-04-12 20:59   ` erik quanstrom
  2012-04-12 19:20     ` cinap_lenrek
  0 siblings, 1 reply; 16+ messages in thread
From: erik quanstrom @ 2012-04-12 20:59 UTC (permalink / raw)
  To: 9fans

> also, the compressed image format has a similar limitation. we changed
> writememimage to produce uncompressed images if the compressed
> blocksize would exceed the buffer.

so only small images are compressed? :-)

- erik



^ permalink raw reply	[flat|nested] 16+ messages in thread

* Re: [9fans] page fit to window does not work on large jpegs
  2012-04-12 19:20     ` cinap_lenrek
@ 2012-04-12 21:35       ` erik quanstrom
  2012-04-13  7:38         ` Charles Forsyth
  0 siblings, 1 reply; 16+ messages in thread
From: erik quanstrom @ 2012-04-12 21:35 UTC (permalink / raw)
  To: 9fans

On Thu Apr 12 17:22:53 EDT 2012, cinap_lenrek@gmx.de wrote:
> just the very wide ones will degrade to uncompressed
> format. the alternative would be changing devdraw
> to accept infinitely long draw rpcs split over multiple
> writes. would require changes in drawterm, inferno, 9vx
> plan9... doesnt seem worth the trouble.

64kb would seem a big enough limit for nearly anything
today.  that would allow for 32bpp images up to 16384
pixels wide if uncompressed.  so why not just make the iounit
bigger?

also, libdraw shouldn't be making decisions about how wide is
too wide.  it should delegate to the device.

- erik



^ permalink raw reply	[flat|nested] 16+ messages in thread

* Re: [9fans] page fit to window does not work on large jpegs
  2012-04-12 21:35       ` erik quanstrom
@ 2012-04-13  7:38         ` Charles Forsyth
  2012-04-13  7:39           ` Charles Forsyth
       [not found]           ` <CAOw7k5iv+gxQKsv33tcGdx0FJ3F68EwaVXDqR1HF=_7CnzsyPg@mail.gmail.c>
  0 siblings, 2 replies; 16+ messages in thread
From: Charles Forsyth @ 2012-04-13  7:38 UTC (permalink / raw)
  To: Fans of the OS Plan 9 from Bell Labs

[-- Attachment #1: Type: text/plain, Size: 252 bytes --]

It's not the library's choice: anything along the way can further restrict
IO unit, but 8k+IOHDR is a reasonable minimum for

On 12 April 2012 22:35, erik quanstrom <quanstro@quanstro.net> wrote:

>  so why not just make the iounit
> bigger?
>

[-- Attachment #2: Type: text/html, Size: 508 bytes --]

^ permalink raw reply	[flat|nested] 16+ messages in thread

* Re: [9fans] page fit to window does not work on large jpegs
  2012-04-13  7:38         ` Charles Forsyth
@ 2012-04-13  7:39           ` Charles Forsyth
       [not found]           ` <CAOw7k5iv+gxQKsv33tcGdx0FJ3F68EwaVXDqR1HF=_7CnzsyPg@mail.gmail.c>
  1 sibling, 0 replies; 16+ messages in thread
From: Charles Forsyth @ 2012-04-13  7:39 UTC (permalink / raw)
  To: Fans of the OS Plan 9 from Bell Labs

[-- Attachment #1: Type: text/plain, Size: 123 bytes --]

 ... graphics

On 13 April 2012 08:38, Charles Forsyth <charles.forsyth@gmail.com> wrote:

> a reasonable minimum for

[-- Attachment #2: Type: text/html, Size: 356 bytes --]

^ permalink raw reply	[flat|nested] 16+ messages in thread

* Re: [9fans] page fit to window does not work on large jpegs
  2012-04-13 12:13             ` erik quanstrom
@ 2012-04-13 10:37               ` cinap_lenrek
  2012-04-13 12:45                 ` Charles Forsyth
  0 siblings, 1 reply; 16+ messages in thread
From: cinap_lenrek @ 2012-04-13 10:37 UTC (permalink / raw)
  To: 9fans

thats basicly what we did too, plus that if dy <= 0, we
split the scanline that fits in the display buffer and
recursively call unloadimage() on the rest instead of
failing.

the same thing is done with loadimage.

its just writememimage() wich uses a constant for the
chunksize because it doesnt have a bufsize negotiated
from 9p i/o unit by libdraw.

--
cinap



^ permalink raw reply	[flat|nested] 16+ messages in thread

* Re: [9fans] page fit to window does not work on large jpegs
  2012-04-13 12:45                 ` Charles Forsyth
@ 2012-04-13 10:49                   ` cinap_lenrek
  0 siblings, 0 replies; 16+ messages in thread
From: cinap_lenrek @ 2012-04-13 10:49 UTC (permalink / raw)
  To: 9fans

yep, figured that out :)

--
cinap



^ permalink raw reply	[flat|nested] 16+ messages in thread

* Re: [9fans] page fit to window does not work on large jpegs
       [not found]           ` <CAOw7k5iv+gxQKsv33tcGdx0FJ3F68EwaVXDqR1HF=_7CnzsyPg@mail.gmail.c>
@ 2012-04-13 12:13             ` erik quanstrom
  2012-04-13 10:37               ` cinap_lenrek
  0 siblings, 1 reply; 16+ messages in thread
From: erik quanstrom @ 2012-04-13 12:13 UTC (permalink / raw)
  To: 9fans

On Fri Apr 13 03:40:36 EDT 2012, charles.forsyth@gmail.com wrote:

>  ... graphics
>
> On 13 April 2012 08:38, Charles Forsyth <charles.forsyth@gmail.com> wrote:
>
> > a reasonable minimum for

except for the fact it's not.  even something like a droid x takes
too wide a picture.  (>3200 pixels wide.)

this is the change i made, which should give you 64k on a terminal,
and drawterm, if you change the iounit.

; diff -c `{yesterday -n2 unloadimage.c} unloadimage.c
/n/dump/2012/0411/sys/src/libdraw/unloadimage.c:28,34 - unloadimage.c:28,34
  			werrstr("unloadimage: %r");
  			return -1;
  		}
- 		dy = 8000/bpl;
+ 		dy = i->display->bufsize/bpl;
  		if(dy <= 0){
  			werrstr("unloadimage: image too wide");
  			return -1;

- erik



^ permalink raw reply	[flat|nested] 16+ messages in thread

* Re: [9fans] page fit to window does not work on large jpegs
  2012-04-13 10:37               ` cinap_lenrek
@ 2012-04-13 12:45                 ` Charles Forsyth
  2012-04-13 10:49                   ` cinap_lenrek
  0 siblings, 1 reply; 16+ messages in thread
From: Charles Forsyth @ 2012-04-13 12:45 UTC (permalink / raw)
  To: Fans of the OS Plan 9 from Bell Labs

[-- Attachment #1: Type: text/plain, Size: 383 bytes --]

Yes, that's a better approach. You need to (try to) adapt to the IO unit as
received, because it can be renegotiated at any Tversion.

On 13 April 2012 11:37, <cinap_lenrek@gmx.de> wrote:

> thats basicly what we did too, plus that if dy <= 0, we
> split the scanline that fits in the display buffer and
> recursively call unloadimage() on the rest instead of
> failing.
>

[-- Attachment #2: Type: text/html, Size: 649 bytes --]

^ permalink raw reply	[flat|nested] 16+ messages in thread

end of thread, other threads:[~2012-04-13 12:45 UTC | newest]

Thread overview: 16+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2012-04-08 18:35 [9fans] page fit to window does not work on large jpegs Ingo Krabbe
2012-04-12 17:47 ` andrey mirtchovski
2012-04-12 18:23   ` Ingo Krabbe
2012-04-12 18:31     ` erik quanstrom
2012-04-12 20:43       ` Ingo Krabbe
2012-04-12 20:46         ` erik quanstrom
2012-04-12 18:56 ` cinap_lenrek
2012-04-12 20:59   ` erik quanstrom
2012-04-12 19:20     ` cinap_lenrek
2012-04-12 21:35       ` erik quanstrom
2012-04-13  7:38         ` Charles Forsyth
2012-04-13  7:39           ` Charles Forsyth
     [not found]           ` <CAOw7k5iv+gxQKsv33tcGdx0FJ3F68EwaVXDqR1HF=_7CnzsyPg@mail.gmail.c>
2012-04-13 12:13             ` erik quanstrom
2012-04-13 10:37               ` cinap_lenrek
2012-04-13 12:45                 ` Charles Forsyth
2012-04-13 10:49                   ` cinap_lenrek

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).