--- a/JPEGReader.st Wed Apr 16 22:57:02 1997 +0200
+++ b/JPEGReader.st Wed Apr 16 23:15:24 1997 +0200
@@ -10,8 +10,6 @@
hereby transferred.
"
-'From Smalltalk/X, Version:3.1.6 on 16-apr-1997 at 9:09:50 pm' !
-
ImageReader subclass:#JPEGReader
instanceVariableNames:'jpeg_decompress_struct jpeg_error_mgr_struct decompressBuffer
colorComponents forceGrayscale forceDitherMode'
@@ -125,18 +123,10 @@
"
Reader for JPEG images.
- This is a quick&dirty hack, using the PD djpeg tool to convert
- the JPG image to PNM first, then reads the PNM image using PBMReader.
-
- Of course, this is slower than it should be. If lots of JPG reading
- is done, this class should be rewritten, to directly call the (C) JPG
- decoding functions.
+ This uses the libpeg library to read the image
Only reading of files is supported.
- CAVEAT:
- you have to have the djpeg program installed.
-
[See also:]
Image Form Icon
BlitImageReader FaceReader GIFReader PBMReader PCXReader
@@ -193,7 +183,7 @@
!JPEGReader methodsFor:'private'!
create_jpeg_decompress_struct
- |structSize fp|
+ |errMgrStructSize decompressStructSize fp|
fp := inStream filePointer.
fp isNil ifTrue:[
@@ -202,16 +192,12 @@
].
%{
- structSize = __MKSMALLINT(sizeof(struct jpeg_error_mgr));
+ errMgrStructSize = __MKSMALLINT(sizeof(struct jpeg_error_mgr));
+ decompressStructSize = __MKSMALLINT(sizeof(struct jpeg_decompress_struct));
%}.
- jpeg_error_mgr_struct := ExternalBytes unprotectedNew:structSize.
-
-%{
- structSize = __MKSMALLINT(sizeof(struct jpeg_decompress_struct));
-%}.
-
- jpeg_decompress_struct := ExternalBytes unprotectedNew:structSize.
+ jpeg_error_mgr_struct := ExternalBytes unprotectedNew:errMgrStructSize.
+ jpeg_decompress_struct := ExternalBytes unprotectedNew:decompressStructSize.
%{
struct jpeg_decompress_struct *cinfoPtr;
@@ -313,36 +299,6 @@
!
-decompressChunk
-%{
- struct jpeg_decompress_struct *cinfoPtr;
- char *rgbRow;
- OBJ j_d_s = __INST(jpeg_decompress_struct);
- int num_scanlines;
- JSAMPROW rowPointers[4];
-
- if (__isExternalBytes(j_d_s)
- && __isByteArray(__INST(decompressBuffer))) {
- cinfoPtr = (struct jpeg_decompress_struct *)(__externalBytesAddress(j_d_s));
- rgbRow = __ByteArrayInstPtr(__INST(decompressBuffer))->ba_element;
-
- rowPointers[0] = (JSAMPROW) rgbRow;
- rowPointers[1] = NULL;
- rowPointers[2] = NULL;
- rowPointers[3] = NULL;
-
- if (cinfoPtr->output_scanline < cinfoPtr->output_height) {
- num_scanlines = jpeg_read_scanlines(cinfoPtr,
- rowPointers,
- 1);
- RETURN (__MKSMALLINT(num_scanlines));
- }
- RETURN (__MKSMALLINT(0));
- }
-%}.
- self halt.
-!
-
decompressChunkInto:aByteArray startingAt:index
%{
struct jpeg_decompress_struct *cinfoPtr;
@@ -392,8 +348,6 @@
!
start_decompress
- decompressBuffer := ByteArray new:(width * colorComponents).
-
%{
struct jpeg_decompress *cinfoPtr;
OBJ j_d_s = __INST(jpeg_decompress_struct);
@@ -458,6 +412,6 @@
!JPEGReader class methodsFor:'documentation'!
version
- ^ '$Header: /cvs/stx/stx/libview2/JPEGReader.st,v 1.20 1997-04-16 20:11:53 cg Exp $'
+ ^ '$Header: /cvs/stx/stx/libview2/JPEGReader.st,v 1.21 1997-04-16 21:15:24 cg Exp $'
! !
JPEGReader initialize!