Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > comp.lang.forth > #11953 > unrolled thread

code for reading gif/png files

Started byKrishna Myneni <krishna.myneni@ccreweb.org>
First post2012-05-07 03:56 -0700
Last post2012-05-11 03:33 -0700
Articles 12 — 5 participants

Back to article view | Back to comp.lang.forth


Contents

  code for reading gif/png files Krishna Myneni <krishna.myneni@ccreweb.org> - 2012-05-07 03:56 -0700
    Re: code for reading gif/png files mhx@iae.nl (Marcel Hendrix) - 2012-05-07 21:21 +0200
    Re: code for reading gif/png files mhx@iae.nl (Marcel Hendrix) - 2012-05-07 21:27 +0200
      Re: code for reading gif/png files Hans Bezemer <the.beez.speaks@gmail.com> - 2012-05-07 23:36 +0200
      Re: code for reading gif/png files Krishna Myneni <krishna.myneni@ccreweb.org> - 2012-05-07 15:12 -0700
        Re: code for reading gif/png files Krishna Myneni <krishna.myneni@ccreweb.org> - 2012-05-07 16:07 -0700
          Re: code for reading gif/png files Tarkin <tarkin000@gmail.com> - 2012-05-07 17:31 -0700
            Re: code for reading gif/png files Krishna Myneni <krishna.myneni@ccreweb.org> - 2012-05-07 18:28 -0700
              Re: code for reading gif/png files Rugxulo <rugxulo@gmail.com> - 2012-05-07 21:15 -0700
                Re: code for reading gif/png files Krishna Myneni <krishna.myneni@ccreweb.org> - 2012-05-09 05:25 -0700
                  Re: code for reading gif/png files Rugxulo <rugxulo@gmail.com> - 2012-05-09 15:17 -0700
                    Re: code for reading gif/png files Krishna Myneni <krishna.myneni@ccreweb.org> - 2012-05-11 03:33 -0700

#11953 — code for reading gif/png files

FromKrishna Myneni <krishna.myneni@ccreweb.org>
Date2012-05-07 03:56 -0700
Subjectcode for reading gif/png files
Message-ID<b60188e4-ff82-44b7-ba73-d94af2aaf61d@p6g2000yqi.googlegroups.com>
Does anyone know of free (public, GPL, etc) code written in Forth for
reading GIF and/or PNG format image files? As an alternative, there
are C libraries, libpng and giflib, which can be used, but it is
preferable to have Forth source for reading these files.

Even code for reading simple black and white GIF files, with no
animation, would be useful. The application I have in mind, for the
latter, is to display equations from TeX/LaTeX via the tool chain, tex/
latex and dvigif. Code for reading PNG files would be more generally
useful for displaying images.

Krishna

[toc] | [next] | [standalone]


#11962

Frommhx@iae.nl (Marcel Hendrix)
Date2012-05-07 21:21 +0200
Message-ID<80141496988435@frunobulax.edu>
In reply to#11953
Krishna Myneni <krishna.myneni@ccreweb.org> writes Re: FSL contribution available for review

> On Mar 6, 5:07 pm, m...@iae.nl (Marcel Hendrix) wrote:
>> m...@iae.nl (Marcel Hendrix) wrote Re: FSL contribution available for review

>> > Krishna Myneni <krishna.myn...@ccreweb.org> writes Re: FSL contribution available for review
[..]

> One of the nice properties of the Numerov difference equation is that
> the error in the solution goes as O(h^4), where h is the step size
> (see, for example, http://research.physics.illinois.edu/ElectronicStructure/498CQM/lnotes/lec2A.html). 
> Marcel's error calculation with the MPFR library directly shows the
> h^4 error dependence.
[..]

With a small modification Numerov becomes O(h^8).

\ The maximum residual from R = 1.000000e-3  to R = 1.000000e1  is 5.101759e-8  ( n=250 ) ok
\ The maximum residual from R = 1.000000e-3  to R = 1.000000e1  is 1.981971e-10 ( n=500 ) ok
\ The maximum residual from R = 1.000000e-3  to R = 1.000000e1  is 7.837742e-13 ( n=1,000 ) ok
\ The maximum residual from R = 1.000000e-3  to R = 1.000000e1  is 1.463233e-14 ( n=2,000 ) ok

-marcel

-- -------------------------------------------------------------
NEEDS -fsl_util

ANEW -numerov8

FALSE 
  [IF]
	Integration of the 2nd order differential equation
		   y''(x) = f(x,y)
	with Q(x) a given function, using the Numerov algorithm.

	The Numerov algorithm may be expressed as shown in (1),
	and then has an error varying like the eight power of h.

	This implementation uses a function which evaluates f(x,y),
	the initial and final argument values, and the number of steps 
	for the integration.  The stepsize h is computed.

	Usage:
	  Define a word myF ( f: x y -- F{x,y} )
	       ' myF IS Ffunc
	  Prepare arrays, using the array size and the integration limits
	       n Xstart Xend setup
	  Establish initial conditions and Y values
	       Y_0 Y_1 setY
	  Perform integration
	       NumInt
	  Results are in the array Y

	[1] 'Explicit eighth order two-step methods with nine 
	    stages for integrating oscillatory problems', Ch. Tsitouras.
[THEN]


#10 =: st \ stages

st FLOAT ARRAY c{        
c{ st }FREAD
	-1e 0e -1.618033988749895e -0.08935969452190693e -0.7180027509073757e 0.7180027509073757e -0.25e 0.25e -1e 1e

st FLOAT ARRAY b{        
b{ st }FREAD
	0.02267478608411768e 0e 0e 0e 0.1091598371161353e 0.1091598371161353e  0.3880338950775969e 0.3880338950775969e -0.01986851827784987e 0.002806267806267806e

st st FLOAT MATRIX a{{        
a{{ st st }}FREAD
	 0e 			0e 		      0e 		       0e 		     0e 		   0e 			    0e 			  0e 			0e 		     0e 
	 0e 			0e 		      0e 		       0e 		     0e 		   0e 			    0e 			  0e 			0e 		     0e 
	 0.4363389981249825e    0.06366100187501753e  0e                       0e                    0e                    0e                       0e                    0e                    0e                   0e
	-0.02663944838475621e  -0.02138085097354293e  0.007333029599869930e    0e                    0e                    0e                       0e                    0e                    0e                   0e
	-0.05259994463359025e   0.1179873479656171e   0.006223764486158627e   -0.1728485681165938e   0e                    0e                       0e                    0e                    0e                   0e
	-0.1594931414841811e    1.756644381705087e    0.002177668974400012e   -1.462560200318788e    0.4799966417324492e   0e                       0e                    0e                    0e                   0e
	-0.01315251843525407e   0.08148753879227717e  0.002255441346558031e   -0.1407999204529257e  -0.02359301393743279e  0.00005247268677732879e  0e                    0e                    0e                   0e
	 0.1182251406950030e   -0.2071467658425108e  -0.009902612273876664e    0.2377506314405291e  -0.1720715921748083e   0.008456715906120000e    0.1809384822495436e   0e                    0e                   0e
	 0.6545342597532786e    4.968502507588174e   -0.05384950599580273e    -4.016696408666935e   -1.055358930155700e    0.2067362330539400e      1.043495190976432e   -1.747363346553386e    0e                   0e
	-0.2731258141928670e  -19.26209659195308e     0.2868033393908071e     21.50877058850632e    -1.286133152186278e    0.7520725477949123e     -1.229894203564763e    0.6765130737370460e  -0.1729097875320912e  0e

\ Initialization

0     VALUE n               ( 1 + number of steps / integer greater than 1 )
FALSE VALUE used?           ( have arrays already been allocated? )
0e   FVALUE h               ( stepsize )
   
   FLOAT DARRAY Y{         
   FLOAT DARRAY X{         
st FLOAT ARRAY  F{         

DEFER Ffunc

:NONAME  ( f: x y -- f{x} )  F2DROP 0e ; IS Ffunc

\ Allocate arrays and compute h and X values

: setarrays  ( n -- )
	TO n
	used? IF  X{ }free  Y{ }free  ENDIF
	X{ n }malloc  Y{ n }malloc
	TRUE TO used? ;        

: stepsize  ( f: Xstart Xend -- Xstart h ) FOVER F- n 1- S>F F/ FDUP TO h ;        

: fillX  ( f: Xstart h -- )
	X{ n 0 DO  DUP F2DUP  		( f: Xstart h Xstart h )
		   I S>F F*  F+  I } F! ( f: Xstart h )
	     LOOP  DROP F2DROP ;        

: F*b    ( F: -- r ) 0e  st 0 ?DO  F{ I } F@  b{    I  } F@  F* F+  LOOP ;
: F*a(o) ( row -- ) ( F: -- r )	LOCALS| row | 0e  st 0 ?DO  F{ I } F@  a{{ row I }} F@  F* F+  LOOP ;

: setup ( n -- ) ( f: Xstart Xend -- ) setarrays stepsize fillX ;
: setY  ( f: Y_0 Y_1 -- )  Y{ 1 } F!  Y{ 0 } F!  ;

: NumInt ( -- )
	0e 			    FLOCAL f0
	X{ 0 } F@  Y{ 0 } F@  Ffunc FLOCAL f1
	h FSQR 			    FLOCAL h^2
	n 1- 1 
	    ?DO		 \ first stage
		f1              	   TO f0  f0 F{ 0 } F!
		X{ I } F@ Y{ I } F@  Ffunc TO f1  f1 F{ 1 } F!
		st 2 ?DO \ another 8 stages
			c{ I } F@ h F* X{ J    } F@ F+
			c{ I } F@ F1+  Y{ J    } F@ F*  
			c{ I } F@      Y{ J 1- } F@ F*  F- 
			h^2  I F*a(o) F*  F+
			( x y ) Ffunc  F{ I } F!
		    LOOP
		Y{ I } F@ F2*  Y{ I 1- } F@ F-  h^2 F*b F*  F+  Y{ I 1+ } F!
	   LOOP ;

[toc] | [prev] | [next] | [standalone]


#11963

Frommhx@iae.nl (Marcel Hendrix)
Date2012-05-07 21:27 +0200
Message-ID<13081496988435@frunobulax.edu>
In reply to#11953
Krishna Myneni <krishna.myneni@ccreweb.org> writes Re: code for reading gif/png files

> Does anyone know of free (public, GPL, etc) code written in Forth for
> reading GIF and/or PNG format image files? 
[..]
> The application I have in mind, for the
> latter, is to display equations from TeX/LaTeX via the tool chain, tex/
> latex and dvigif. Code for reading PNG files would be more generally
> useful for displaying images.

Doesn't TeX/dvi support pbm? That is an almost trivial format. See
the Great Computer Language Shootout http://shootout.alioth.debian.org/
mandelbrot.gforth, Contributed by Ian Osgood

-marcel

[toc] | [prev] | [next] | [standalone]


#11965

FromHans Bezemer <the.beez.speaks@gmail.com>
Date2012-05-07 23:36 +0200
Message-ID<4fa8401a$0$6950$e4fe514c@news2.news.xs4all.nl>
In reply to#11963
Marcel Hendrix wrote:

> Krishna Myneni <krishna.myneni@ccreweb.org> writes Re: code for reading
> gif/png files
> 
>> Does anyone know of free (public, GPL, etc) code written in Forth for
>> reading GIF and/or PNG format image files?
> [..]
>> The application I have in mind, for the
>> latter, is to display equations from TeX/LaTeX via the tool chain, tex/
>> latex and dvigif. Code for reading PNG files would be more generally
>> useful for displaying images.
> 
> Doesn't TeX/dvi support pbm? That is an almost trivial format. See
> the Great Computer Language Shootout http://shootout.alioth.debian.org/
> mandelbrot.gforth, Contributed by Ian Osgood
When it's about PBM, 4tH offers a large PBM library, written by David
Johnson.

Hans Bezemer

[toc] | [prev] | [next] | [standalone]


#11966

FromKrishna Myneni <krishna.myneni@ccreweb.org>
Date2012-05-07 15:12 -0700
Message-ID<585b344d-4470-4743-9bbd-922eea37f0d0@m16g2000yqc.googlegroups.com>
In reply to#11963
On May 7, 2:27 pm, m...@iae.nl (Marcel Hendrix) wrote:
> Krishna Myneni <krishna.myn...@ccreweb.org> writes Re: code for reading gif/png files
>
>
>
> > Does anyone know of free (public, GPL, etc) code written in Forth for
> > reading GIF and/or PNG format image files?
> [..]
> > The application I have in mind, for the
> > latter, is to display equations from TeX/LaTeX via the tool chain, tex/
> > latex and dvigif. Code for reading PNG files would be more generally
> > useful for displaying images.
>
> Doesn't TeX/dvi support pbm? That is an almost trivial format. See
> the Great Computer Language Shootouthttp://shootout.alioth.debian.org/
> mandelbrot.gforth, Contributed by Ian Osgood
>
> -marcel

Thanks. There's a two-step solution to get from dvi to pbm:

1) dvips to convert from dvi to postscript
2) dvipnm to convert from ps to pbm (there's a -pbm option)

This should work. There's also a program called dvi2bitmap which can
generate xbm files for easy import to X11 code; however, I dislike it
because it is a text format.

Krishna

[toc] | [prev] | [next] | [standalone]


#11967

FromKrishna Myneni <krishna.myneni@ccreweb.org>
Date2012-05-07 16:07 -0700
Message-ID<7e70210e-283d-4333-9ad9-2acacfe231cc@m16g2000yqc.googlegroups.com>
In reply to#11966
On May 7, 5:12 pm, Krishna Myneni <krishna.myn...@ccreweb.org> wrote:
> On May 7, 2:27 pm, m...@iae.nl (Marcel Hendrix) wrote:
>
>
>
>
>
>
>
>
>
> > Krishna Myneni <krishna.myn...@ccreweb.org> writes Re: code for reading gif/png files
>
> > > Does anyone know of free (public, GPL, etc) code written in Forth for
> > > reading GIF and/or PNG format image files?
> > [..]
> > > The application I have in mind, for the
> > > latter, is to display equations from TeX/LaTeX via the tool chain, tex/
> > > latex and dvigif. Code for reading PNG files would be more generally
> > > useful for displaying images.
>
> > Doesn't TeX/dvi support pbm? That is an almost trivial format. See
> > the Great Computer Language Shootouthttp://shootout.alioth.debian.org/
> > mandelbrot.gforth, Contributed by Ian Osgood
>
> > -marcel
>
> Thanks. There's a two-step solution to get from dvi to pbm:
>
> 1) dvips to convert from dvi to postscript
> 2) dvipnm to convert from ps to pbm (there's a -pbm option)
>
> This should work. There's also a program called dvi2bitmap which can
> generate xbm files for easy import to X11 code; however, I dislike it
> because it is a text format.
>
> Krishna

Blechh! The tools run, but the pbm file shows no image when viewed on
my system, using two different viewers. The intermediate ps file is
also large. This might be made to work, but it's far from an optimal
solution. In contrast, dvigif (which is really dvipng with the -gif
option) makes a very nice compact file. How hard can it be to read a
simple gif bitmap??

Krishna

[toc] | [prev] | [next] | [standalone]


#11968

FromTarkin <tarkin000@gmail.com>
Date2012-05-07 17:31 -0700
Message-ID<a7402b97-74f6-427a-84c9-a630cb22ac1d@r2g2000pbs.googlegroups.com>
In reply to#11967
On May 7, 7:07 pm, Krishna Myneni <krishna.myn...@ccreweb.org> wrote:
> On May 7, 5:12 pm, Krishna Myneni <krishna.myn...@ccreweb.org> wrote:
>
>
>
>
>
>
>
>
>
> > On May 7, 2:27 pm, m...@iae.nl (Marcel Hendrix) wrote:
>
> > > Krishna Myneni <krishna.myn...@ccreweb.org> writes Re: code for reading gif/png files
>
> > > > Does anyone know of free (public, GPL, etc) code written in Forth for
> > > > reading GIF and/or PNG format image files?
> > > [..]
> > > > The application I have in mind, for the
> > > > latter, is to display equations from TeX/LaTeX via the tool chain, tex/
> > > > latex and dvigif. Code for reading PNG files would be more generally
> > > > useful for displaying images.
>
> > > Doesn't TeX/dvi support pbm? That is an almost trivial format. See
> > > the Great Computer Language Shootouthttp://shootout.alioth.debian.org/
> > > mandelbrot.gforth, Contributed by Ian Osgood
>
> > > -marcel
>
> > Thanks. There's a two-step solution to get from dvi to pbm:
>
> > 1) dvips to convert from dvi to postscript
> > 2) dvipnm to convert from ps to pbm (there's a -pbm option)
>
> > This should work. There's also a program called dvi2bitmap which can
> > generate xbm files for easy import to X11 code; however, I dislike it
> > because it is a text format.
>
> > Krishna
>
> Blechh! The tools run, but the pbm file shows no image when viewed on
> my system, using two different viewers. The intermediate ps file is
> also large. This might be made to work, but it's far from an optimal
> solution. In contrast, dvigif (which is really dvipng with the -gif
> option) makes a very nice compact file. How hard can it be to read a
> simple gif bitmap??
>
> Krishna

It's not, at least after a cursory glance @ wikipedia and
according to "Programming Web Graphics with Perl and GNU Software"
by Shawn Wallace.

Given your recent work with X11, and your history with mathematics
and forth, I would have assumed that this would be trivial for you
to develop.

I am unaware of any work in forth.

Am I right that you are asking before (re)inventing the wheel?

TTFN,
  Tarkin

[toc] | [prev] | [next] | [standalone]


#11969

FromKrishna Myneni <krishna.myneni@ccreweb.org>
Date2012-05-07 18:28 -0700
Message-ID<809936b3-1fc0-4cff-bd59-0ffa65ecfbbe@m16g2000yqc.googlegroups.com>
In reply to#11968
On May 7, 7:31 pm, Tarkin <tarkin...@gmail.com> wrote:
> On May 7, 7:07 pm, Krishna Myneni <krishna.myn...@ccreweb.org> wrote:
>
>
>
>
>
>
>
>
>
> > On May 7, 5:12 pm, Krishna Myneni <krishna.myn...@ccreweb.org> wrote:
>
> > > On May 7, 2:27 pm, m...@iae.nl (Marcel Hendrix) wrote:
>
> > > > Krishna Myneni <krishna.myn...@ccreweb.org> writes Re: code for reading gif/png files
>
> > > > > Does anyone know of free (public, GPL, etc) code written in Forth for
> > > > > reading GIF and/or PNG format image files?
> > > > [..]
> > > > > The application I have in mind, for the
> > > > > latter, is to display equations from TeX/LaTeX via the tool chain, tex/
> > > > > latex and dvigif. Code for reading PNG files would be more generally
> > > > > useful for displaying images.
>
> > > > Doesn't TeX/dvi support pbm? That is an almost trivial format. See
> > > > the Great Computer Language Shootouthttp://shootout.alioth.debian.org/
> > > > mandelbrot.gforth, Contributed by Ian Osgood
>
> > > > -marcel
>
> > > Thanks. There's a two-step solution to get from dvi to pbm:
>
> > > 1) dvips to convert from dvi to postscript
> > > 2) dvipnm to convert from ps to pbm (there's a -pbm option)
>
> > > This should work. There's also a program called dvi2bitmap which can
> > > generate xbm files for easy import to X11 code; however, I dislike it
> > > because it is a text format.
>
> > > Krishna
>
> > Blechh! The tools run, but the pbm file shows no image when viewed on
> > my system, using two different viewers. The intermediate ps file is
> > also large. This might be made to work, but it's far from an optimal
> > solution. In contrast, dvigif (which is really dvipng with the -gif
> > option) makes a very nice compact file. How hard can it be to read a
> > simple gif bitmap??
>
> > Krishna
>
> It's not, at least after a cursory glance @ wikipedia and
> according to "Programming Web Graphics with Perl and GNU Software"
> by Shawn Wallace.
>

Good. The black and white bitmaps should be even easier than the
general case of color images, and that would suffice to display
equations typeset in TeX within an X window. Thanks for the reference.

> Given your recent work with X11, and your history with mathematics
> and forth, I would have assumed that this would be trivial for you
> to develop.
>

I'll make the standard disclaimer that is made for stock portfolios:
Past Performance is No Guarantee of Future Results.

Given that disclaimer, the problem is not so much that it is a
difficult thing to do, but that it is time consuming. At the heart of
GIF, there's a LZW compression/decompression algorithm, and that may
first need to be written and checked out. Wil Baden had previously
posted Forth code for LZ compression.

> I am unaware of any work in forth.
>
> Am I right that you are asking before (re)inventing the wheel?
>

Correct. Time is a precious commodity, and I'd prefer to make use of
existing code. There are quite a few here in c.l.f. who are
better programmers than I.

Krishna

[toc] | [prev] | [next] | [standalone]


#11971

FromRugxulo <rugxulo@gmail.com>
Date2012-05-07 21:15 -0700
Message-ID<d95c0327-f4c3-4c82-8394-78ebe1b6dc87@21g2000yqy.googlegroups.com>
In reply to#11969
Hi,

On May 7, 8:28 pm, Krishna Myneni <krishna.myn...@ccreweb.org> wrote:
>
> > > > > > Does anyone know of free (public, GPL, etc) code written in Forth for
> > > > > > reading GIF and/or PNG format image files?
> > > > > [..]
> > > > > > The application I have in mind, for the
> > > > > > latter, is to display equations from TeX/LaTeX via the tool chain, tex/
> > > > > > latex and dvigif. Code for reading PNG files would be more generally
> > > > > > useful for displaying images.
> > >
> > > In contrast, dvigif (which is really dvipng with the -gif
> > > option) makes a very nice compact file. How hard can it be to read a
> > > simple gif bitmap??
>
> the problem is not so much that it is a
> difficult thing to do, but that it is time consuming. At the heart of
> GIF, there's a LZW compression/decompression algorithm, and that may
> first need to be written and checked out. Wil Baden had previously
> posted Forth code for LZ compression.

IIRC, there are two variants of GIF, 87 and 89. The compression is LZW
(not just LZ) but optional. So if you can control the generation, it
will be much easier if you can disable compression. Though I have seen
UNARC (for .arc files) on Taygeta FTP semi-recently, and since .arc
used LZW, that may simplify things for you. As for .GIF, dunno, and
it's kinda an old 8-bit format, so many don't use it much anymore.
Though of course it's quite easy to find old code for reading it (in
QB, C, etc), as I vaguely remember seeing such online, if you think
you can handle it. PNG of course is a bit more complex.

[toc] | [prev] | [next] | [standalone]


#12113

FromKrishna Myneni <krishna.myneni@ccreweb.org>
Date2012-05-09 05:25 -0700
Message-ID<47bcaf72-10d1-4e44-ab54-6bb2d26ec85e@23g2000yqo.googlegroups.com>
In reply to#11971
On May 7, 11:15 pm, Rugxulo <rugx...@gmail.com> wrote:
> Hi,
>
> On May 7, 8:28 pm, Krishna Myneni <krishna.myn...@ccreweb.org> wrote:
>
>
>
>
>
>
>
>
>
>
>
> > > > > > > Does anyone know of free (public, GPL, etc) code written in Forth for
> > > > > > > reading GIF and/or PNG format image files?
> > > > > > [..]
> > > > > > > The application I have in mind, for the
> > > > > > > latter, is to display equations from TeX/LaTeX via the tool chain, tex/
> > > > > > > latex and dvigif. Code for reading PNG files would be more generally
> > > > > > > useful for displaying images.
>
> > > > In contrast, dvigif (which is really dvipng with the -gif
> > > > option) makes a very nice compact file. How hard can it be to read a
> > > > simple gif bitmap??
>
> > the problem is not so much that it is a
> > difficult thing to do, but that it is time consuming. At the heart of
> > GIF, there's a LZW compression/decompression algorithm, and that may
> > first need to be written and checked out. Wil Baden had previously
> > posted Forth code for LZ compression.
>
> IIRC, there are two variants of GIF, 87 and 89. The compression is LZW
> (not just LZ) but optional. So if you can control the generation, it
> will be much easier if you can disable compression. ...

dvigif gives an error for compression level zero ( -z0 option ) ---
don't know why.

>  Though I have seen
> UNARC (for .arc files) on Taygeta FTP semi-recently, and since .arc
> used LZW, that may simplify things for you. ...

Thanks for the pointer.


> As for .GIF, dunno, and
> it's kinda an old 8-bit format, so many don't use it much anymore. ...

It's an old format, and not useful for high-quality images, but the
gif format seems perfect for my present requirement of obtaining and
displaying images of equations typeset by TeX.

> Though of course it's quite easy to find old code for reading it (in
> QB, C, etc), as I vaguely remember seeing such online, if you think
> you can handle it. PNG of course is a bit more complex.

Yes. The older C code will be a useful reference when developing an
equivalent Forth version.

Cheers,
Krishna

[toc] | [prev] | [next] | [standalone]


#12120

FromRugxulo <rugxulo@gmail.com>
Date2012-05-09 15:17 -0700
Message-ID<143745ae-b92c-4165-909d-c20f286f89d1@f27g2000yqc.googlegroups.com>
In reply to#12113
Hi,

On May 9, 7:25 am, Krishna Myneni <krishna.myn...@ccreweb.org> wrote:
> On May 7, 11:15 pm, Rugxulo <rugx...@gmail.com> wrote:
>
> > On May 7, 8:28 pm, Krishna Myneni <krishna.myn...@ccreweb.org> wrote:
>
> > > > > > > > Does anyone know of free (public, GPL, etc) code written in Forth for
> > > > > > > > reading GIF and/or PNG format image files?
> > > > > > > [..]
> > > > > > > > The application I have in mind, for the
> > > > > > > > latter, is to display equations from TeX/LaTeX via the tool chain, tex/
> > > > > > > > latex and dvigif. Code for reading PNG files would be more generally
> > > > > > > > useful for displaying images.
>
> > > > > In contrast, dvigif (which is really dvipng with the -gif
> > > > > option) makes a very nice compact file. How hard can it be to read a
> > > > > simple gif bitmap??
>
> > > the problem is not so much that it is a
> > > difficult thing to do, but that it is time consuming. At the heart of
> > > GIF, there's a LZW compression/decompression algorithm, and that may
> > > first need to be written and checked out. Wil Baden had previously
> > > posted Forth code for LZ compression.
>
> > IIRC, there are two variants of GIF, 87 and 89. The compression is LZW
> > (not just LZ) but optional. So if you can control the generation, it
> > will be much easier if you can disable compression. ...
>
> dvigif gives an error for compression level zero ( -z0 option ) ---
> don't know why.

Doh, not surprised. Nothing ever is as easy as it seems. Chalk it up
to Murphy's Law ....

> >  Though I have seen
> > UNARC (for .arc files) on Taygeta FTP semi-recently, and since .arc
> > used LZW, that may simplify things for you. ...
>
> Thanks for the pointer.

Oops, I think I meant RDARC by Kevin Pauba.

ftp://ftp.taygeta.com/pub/forth/Archive/ibm/rdarc.arc

There's a (DOS w/ TP src) unpacker for .ARC here, so presumably you
can run it via DOSBox or DOSEMU (or maybe even WINE):

http://www.vectorbd.com/bfd/pascal/dearc40.lzh

Oops, stupid LZH. Well, there's a *nix port of that too (though maybe
not in Debian). I just use the DJGPP build (source .tar.bz2 available
below too).   ;-)

http://www.rahul.net/dkaufman/

> > As for .GIF, dunno, and
> > it's kinda an old 8-bit format, so many don't use it much anymore. ...
>
> It's an old format, and not useful for high-quality images, but the
> gif format seems perfect for my present requirement of obtaining and
> displaying images of equations typeset by TeX.

Here's a spec sheet for GIF 89:

http://www.petesqbsite.com/sections/tutorials/zines/qbtimes/4-gif89a.txt

Wotsit.org has a few files re: GIF (87, 89, LZW) also:

http://www.wotsit.org/list.asp?page=2&fc=1&search=&al=

There are other LZW-based tools too, but I'm not sure how far you want
to delve (and I've never bothered personally, so I won't be much
help). You could probably ask in news://comp.compression if needed.

> > Though of course it's quite easy to find old code for reading it (in
> > QB, C, etc), as I vaguely remember seeing such online, if you think
> > you can handle it. PNG of course is a bit more complex.
>
> Yes. The older C code will be a useful reference when developing an
> equivalent Forth version.

I'm sure I could find tons of DOS code for this format. Here's a
picture viewer that supports GIF and a few other formats. (Granted,
XPL0 is somewhat obscure, but it's mostly Pascal-ish):

http://www.xpl0.org/SEE.ZIP

And here's one (gifload.zip) in QBASIC source:   http://www.qb45.com/download.php?id=618

[toc] | [prev] | [next] | [standalone]


#12140

FromKrishna Myneni <krishna.myneni@ccreweb.org>
Date2012-05-11 03:33 -0700
Message-ID<df5d8df0-82a3-40a7-b070-6625082194c2@q5g2000yqk.googlegroups.com>
In reply to#12120
On May 9, 5:17 pm, Rugxulo <rugx...@gmail.com> wrote:
> Hi,
>
> On May 9, 7:25 am, Krishna Myneni <krishna.myn...@ccreweb.org> wrote:
>
>
>
>
>
>
>
>
>
> > On May 7, 11:15 pm, Rugxulo <rugx...@gmail.com> wrote:
>
> > > On May 7, 8:28 pm, Krishna Myneni <krishna.myn...@ccreweb.org> wrote:
>
> > > > > > > > > Does anyone know of free (public, GPL, etc) code written in Forth for
> > > > > > > > > reading GIF and/or PNG format image files?
> > > > > > > > [..]
> > > > > > > > > The application I have in mind, for the
> > > > > > > > > latter, is to display equations from TeX/LaTeX via the tool chain, tex/
> > > > > > > > > latex and dvigif. Code for reading PNG files would be more generally
> > > > > > > > > useful for displaying images.
>
> > > > > > In contrast, dvigif (which is really dvipng with the -gif
> > > > > > option) makes a very nice compact file. How hard can it be to read a
> > > > > > simple gif bitmap??
>
> > > > the problem is not so much that it is a
> > > > difficult thing to do, but that it is time consuming. At the heart of
> > > > GIF, there's a LZW compression/decompression algorithm, and that may
> > > > first need to be written and checked out. Wil Baden had previously
> > > > posted Forth code for LZ compression.
>
> > > IIRC, there are two variants of GIF, 87 and 89. The compression is LZW
> > > (not just LZ) but optional. So if you can control the generation, it
> > > will be much easier if you can disable compression. ...
>
> > dvigif gives an error for compression level zero ( -z0 option ) ---
> > don't know why.
>
> Doh, not surprised. Nothing ever is as easy as it seems. Chalk it up
> to Murphy's Law ....
>
> > >  Though I have seen
> > > UNARC (for .arc files) on Taygeta FTP semi-recently, and since .arc
> > > used LZW, that may simplify things for you. ...
>
> > Thanks for the pointer.
>
> Oops, I think I meant RDARC by Kevin Pauba.
>
> ftp://ftp.taygeta.com/pub/forth/Archive/ibm/rdarc.arc
>
> There's a (DOS w/ TP src) unpacker for .ARC here, so presumably you
> can run it via DOSBox or DOSEMU (or maybe even WINE):
>
> http://www.vectorbd.com/bfd/pascal/dearc40.lzh
>
> Oops, stupid LZH. Well, there's a *nix port of that too (though maybe
> not in Debian). I just use the DJGPP build (source .tar.bz2 available
> below too).   ;-)
>
> http://www.rahul.net/dkaufman/
>
> > > As for .GIF, dunno, and
> > > it's kinda an old 8-bit format, so many don't use it much anymore. ...
>
> > It's an old format, and not useful for high-quality images, but the
> > gif format seems perfect for my present requirement of obtaining and
> > displaying images of equations typeset by TeX.
>
> Here's a spec sheet for GIF 89:
>
> http://www.petesqbsite.com/sections/tutorials/zines/qbtimes/4-gif89a.txt
>
> Wotsit.org has a few files re: GIF (87, 89, LZW) also:
>
> http://www.wotsit.org/list.asp?page=2&fc=1&search=&al=
>
> There are other LZW-based tools too, but I'm not sure how far you want
> to delve (and I've never bothered personally, so I won't be much
> help). You could probably ask in news://comp.compression if needed.
>
> > > Though of course it's quite easy to find old code for reading it (in
> > > QB, C, etc), as I vaguely remember seeing such online, if you think
> > > you can handle it. PNG of course is a bit more complex.
>
> > Yes. The older C code will be a useful reference when developing an
> > equivalent Forth version.
>
> I'm sure I could find tons of DOS code for this format. Here's a
> picture viewer that supports GIF and a few other formats. (Granted,
> XPL0 is somewhat obscure, but it's mostly Pascal-ish):
>
> http://www.xpl0.org/SEE.ZIP
>
> And here's one (gifload.zip) in QBASIC source:  http://www.qb45.com/download.php?id=618

Thanks for all of the links! That's a good variety, from which to base
a Forth version of a GIF reader.

Krishna

[toc] | [prev] | [standalone]


Back to top | Article view | comp.lang.forth


csiph-web