6
|
1 |
"
|
|
2 |
COPYRIGHT (c) 1993 by Claus Gittinger
|
28
|
3 |
All Rights Reserved
|
6
|
4 |
|
|
5 |
This software is furnished under a license and may be used
|
|
6 |
only in accordance with the terms of that license and with the
|
|
7 |
inclusion of the above copyright notice. This software may not
|
|
8 |
be provided or otherwise made available to, or used by, any
|
|
9 |
other person. No title to or ownership of the software is
|
|
10 |
hereby transferred.
|
|
11 |
"
|
|
12 |
|
2
|
13 |
ImageReader subclass:#JPEGReader
|
28
|
14 |
instanceVariableNames:''
|
|
15 |
classVariableNames:''
|
|
16 |
poolDictionaries:''
|
32
|
17 |
category:'Graphics-Images support'
|
2
|
18 |
!
|
|
19 |
|
16
|
20 |
JPEGReader comment:'
|
21
|
21 |
COPYRIGHT (c) 1993 by Claus Gittinger
|
28
|
22 |
All Rights Reserved
|
23
|
23 |
|
43
|
24 |
$Header: /cvs/stx/stx/libview2/JPEGReader.st,v 1.8 1995-02-18 15:57:36 claus Exp $
|
21
|
25 |
'!
|
16
|
26 |
|
21
|
27 |
!JPEGReader class methodsFor:'documentation'!
|
|
28 |
|
|
29 |
copyright
|
|
30 |
"
|
|
31 |
COPYRIGHT (c) 1993 by Claus Gittinger
|
28
|
32 |
All Rights Reserved
|
16
|
33 |
|
21
|
34 |
This software is furnished under a license and may be used
|
|
35 |
only in accordance with the terms of that license and with the
|
|
36 |
inclusion of the above copyright notice. This software may not
|
|
37 |
be provided or otherwise made available to, or used by, any
|
|
38 |
other person. No title to or ownership of the software is
|
|
39 |
hereby transferred.
|
|
40 |
"
|
|
41 |
!
|
16
|
42 |
|
21
|
43 |
version
|
|
44 |
"
|
43
|
45 |
$Header: /cvs/stx/stx/libview2/JPEGReader.st,v 1.8 1995-02-18 15:57:36 claus Exp $
|
21
|
46 |
"
|
|
47 |
!
|
|
48 |
|
|
49 |
documentation
|
|
50 |
"
|
|
51 |
Reader for JPEG images.
|
32
|
52 |
This is a quick&dirty hack, using the PD djpeg tool to convert
|
|
53 |
the JPG image to GIF first, then reads the GIF image using GIFReader.
|
|
54 |
Of course, this is slower than it should be. If lots of JPG reading
|
|
55 |
is done, this class should be rewritten, to directly call the (C) JPG
|
|
56 |
decoding functions.
|
21
|
57 |
"
|
|
58 |
! !
|
16
|
59 |
|
28
|
60 |
!JPEGReader class methodsFor:'initialization'!
|
|
61 |
|
|
62 |
initialize
|
|
63 |
Image fileFormats at:'.jpg' put:self.
|
|
64 |
Image fileFormats at:'.jpeg' put:self.
|
|
65 |
Image fileFormats at:'.JPG' put:self.
|
|
66 |
! !
|
|
67 |
|
43
|
68 |
!JPEGReader class methodsFor:'reading from file'!
|
2
|
69 |
|
|
70 |
fromFile:aFileName
|
|
71 |
"make it the easy way: let djpeg convert it to gif,
|
|
72 |
then let GIFReader read the file"
|
|
73 |
|
|
74 |
|tempFileName reader|
|
|
75 |
|
|
76 |
tempFileName := '/tmp/img' , (OperatingSystem getProcessId printString).
|
32
|
77 |
'JPEGREADER: converting to gif ..' errorPrintNL.
|
2
|
78 |
(OperatingSystem executeCommand:'djpeg -gif ' , aFileName , ' > ' , tempFileName)
|
|
79 |
ifTrue:[
|
28
|
80 |
reader := GIFReader fromFile:tempFileName.
|
|
81 |
OperatingSystem executeCommand:'rm ' , tempFileName.
|
|
82 |
^ reader
|
2
|
83 |
].
|
32
|
84 |
'JPEGREADER: conversion failed ..' errorPrintNL.
|
16
|
85 |
self warn:'cannot execute jpeg converter: djpeg'.
|
2
|
86 |
^ nil
|
|
87 |
|
32
|
88 |
"
|
|
89 |
JPEGReader fromFile:'bitmaps/testimg.jpg'
|
|
90 |
"
|
2
|
91 |
! !
|