main
Matthew Butterick 6 years ago
parent 9b85bb85f2
commit e34d227e3f

@ -22,7 +22,7 @@
[else (open-input-file src)]))
(cond
[(equal? (peek-bytes 2 0 data) (bytes #xff #xd8))
(make-object JPEG (port->bytes data) label)]
(make-object JPEG data label)]
[(equal? (peek-bytes 4 0 data) (apply bytes (cons #x89 (map char->integer '(#\P #\N #\G)))))
(make-object PNG data label)]
[else (raise-argument-error 'PDFImage-open "valid image format" src)]))

@ -8,9 +8,7 @@
(define-subclass object% (JPEG data [label #f])
(define last-ip (current-input-port))
(current-input-port (if (input-port? data)
data
(open-input-bytes data)))
(current-input-port (if (input-port? data) data (open-input-bytes data)))
(unless (equal? (read-16bit-integer) #xffd8)
(error 'JPEG "Start of Input marker byte not found"))
@ -66,6 +64,7 @@
(when (equal? (· this colorSpace) "DeviceCMYK")
(hash-set! (· this obj payload) 'Decode '(1.0 0.0 1.0 0.0 1.0 0.0 1.0 0.0)))
(port-position (· this data) 0)
(send (· this obj) end (· this data))))
(module+ test

@ -1,11 +1,9 @@
#lang racket
(module+ test
(for ([i (in-range 20)])
(define which (string->symbol (format "ptest/test~a" i)))
(println which)
(dynamic-require which #f))
(for ([i (in-range 20)])
(define which (string->symbol (format "ptest/test~a" i)))
(println which)
(dynamic-require which #f))
(require
pitfall/page-test
(submod pitfall/zlib test)))
(require
pitfall/page-test
(submod pitfall/zlib test))
Loading…
Cancel
Save