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
|
199
|
14 |
instanceVariableNames:''
|
|
15 |
classVariableNames:''
|
|
16 |
poolDictionaries:''
|
|
17 |
category:'Graphics-Images support'
|
2
|
18 |
!
|
|
19 |
|
21
|
20 |
!JPEGReader class methodsFor:'documentation'!
|
|
21 |
|
|
22 |
copyright
|
|
23 |
"
|
|
24 |
COPYRIGHT (c) 1993 by Claus Gittinger
|
28
|
25 |
All Rights Reserved
|
16
|
26 |
|
21
|
27 |
This software is furnished under a license and may be used
|
|
28 |
only in accordance with the terms of that license and with the
|
|
29 |
inclusion of the above copyright notice. This software may not
|
|
30 |
be provided or otherwise made available to, or used by, any
|
|
31 |
other person. No title to or ownership of the software is
|
|
32 |
hereby transferred.
|
|
33 |
"
|
|
34 |
!
|
16
|
35 |
|
21
|
36 |
documentation
|
|
37 |
"
|
|
38 |
Reader for JPEG images.
|
199
|
39 |
|
32
|
40 |
This is a quick&dirty hack, using the PD djpeg tool to convert
|
|
41 |
the JPG image to GIF first, then reads the GIF image using GIFReader.
|
199
|
42 |
|
32
|
43 |
Of course, this is slower than it should be. If lots of JPG reading
|
|
44 |
is done, this class should be rewritten, to directly call the (C) JPG
|
|
45 |
decoding functions.
|
199
|
46 |
|
|
47 |
Only reading of files is supported.
|
|
48 |
|
|
49 |
CAVEAT:
|
|
50 |
you have to have the djpeg program installed.
|
|
51 |
|
|
52 |
[See also:]
|
|
53 |
BlitImageReader FaceReader GIFReader PBMReader PCXReader
|
|
54 |
ST80FormReader SunRasterReader TIFFReader WindowsIconReader
|
|
55 |
XBMreader XPMReader XWDReader
|
21
|
56 |
"
|
|
57 |
! !
|
16
|
58 |
|
28
|
59 |
!JPEGReader class methodsFor:'initialization'!
|
|
60 |
|
|
61 |
initialize
|
199
|
62 |
"install myself in the Image classes fileFormat table
|
|
63 |
for the `.jpg', '.jpeg' and '.JPG' extensions."
|
|
64 |
|
28
|
65 |
Image fileFormats at:'.jpg' put:self.
|
|
66 |
Image fileFormats at:'.jpeg' put:self.
|
|
67 |
Image fileFormats at:'.JPG' put:self.
|
199
|
68 |
|
|
69 |
"Modified: 23.4.1996 / 12:28:03 / cg"
|
28
|
70 |
! !
|
|
71 |
|
43
|
72 |
!JPEGReader class methodsFor:'reading from file'!
|
2
|
73 |
|
|
74 |
fromFile:aFileName
|
199
|
75 |
"read a jpg image from a file.
|
|
76 |
Make it the easy way: let djpeg convert it to gif,
|
|
77 |
then let GIFReader read the file."
|
2
|
78 |
|
|
79 |
|tempFileName reader|
|
|
80 |
|
|
81 |
tempFileName := '/tmp/img' , (OperatingSystem getProcessId printString).
|
32
|
82 |
'JPEGREADER: converting to gif ..' errorPrintNL.
|
2
|
83 |
(OperatingSystem executeCommand:'djpeg -gif ' , aFileName , ' > ' , tempFileName)
|
|
84 |
ifTrue:[
|
199
|
85 |
reader := GIFReader fromFile:tempFileName.
|
|
86 |
OperatingSystem executeCommand:'rm ' , tempFileName.
|
|
87 |
^ reader
|
2
|
88 |
].
|
32
|
89 |
'JPEGREADER: conversion failed ..' errorPrintNL.
|
16
|
90 |
self warn:'cannot execute jpeg converter: djpeg'.
|
2
|
91 |
^ nil
|
|
92 |
|
32
|
93 |
"
|
|
94 |
JPEGReader fromFile:'bitmaps/testimg.jpg'
|
|
95 |
"
|
199
|
96 |
|
|
97 |
"Modified: 23.4.1996 / 12:30:12 / cg"
|
2
|
98 |
! !
|
199
|
99 |
|
|
100 |
!JPEGReader class methodsFor:'documentation'!
|
|
101 |
|
|
102 |
version
|
|
103 |
^ '$Header: /cvs/stx/stx/libview2/JPEGReader.st,v 1.12 1996-04-23 10:30:44 cg Exp $'
|
|
104 |
! !
|
|
105 |
JPEGReader initialize!
|