@@ -39,7 +39,8 @@ A bitmap is convertible to @racket['png-bytes] through the
3939 'unknown ]
4040 [bg-color (or/c (is-a?/c color%) #f ) #f ]
4141 [complain-on-failure? any/c #f ]
42- [backing-scale (>/c 0.0 ) 1.0 ])
42+ [backing-scale (>/c 0.0 ) 1.0 ]
43+ [save-data-from-file? any/c #f ])
4344 ([bits bytes?]
4445 [width exact-positive-integer?]
4546 [height exact-positive-integer?]))]{
@@ -78,8 +79,11 @@ When a @racket[bits] byte string is provided: Creates a monochrome
7879 @racket[height] is larger than 8 times the length of @racket[bits],
7980 @|MismatchExn|.
8081
82+ See @method[bitmap% get-data-from-file] for information on @racket[save-data-from-file?]
83+
8184@history[#:changed "1.1 " @elem{Added the @racket[backing-scale]
82- optional arguments.}]}
85+ optional arguments.}
86+ #:changed "1.17 " @elem{Added @racket[save-data-from-file?]}]}
8387
8488@defmethod[(get-argb-pixels [x exact-nonnegative-integer?]
8589 [y exact-nonnegative-integer?]
@@ -113,6 +117,26 @@ Returns the bitmap's @tech{backing scale}.
113117
114118@history[#:added "1.1 " ]}
115119
120+ @defmethod[(get-data-from-file)
121+ (or/c (vector/c (or/c 'unknown 'unknown/mask 'unknown/alpha
122+ 'gif 'gif/mask 'gif/alpha
123+ 'jpeg 'jpeg/alpha
124+ 'png 'png/mask 'png/alpha
125+ 'xbm 'xbm/alpha 'xpm 'xpm/alpha
126+ 'bmp 'bmp/alpha )
127+ (or/c (is-a?/c color%) #f )
128+ (and/c bytes? immutable?)
129+ #:immutable? #t )
130+ #f )]{
131+ If the bitmap data in this bitmap was read from a file
132+ and the @racket[_save-data-from-file?] was passed with
133+ a true value when it was read (either in the constructor
134+ or in @method[bitmap% load-file]), then this method
135+ returns the contents of the loaded file as bytes. Otherwise,
136+ it returns @racket[#f ].
137+
138+ @history[#:added "1.17 " ]
139+ }
116140
117141@defmethod[(get-depth)
118142 exact-nonnegative-integer?]{
@@ -206,7 +230,8 @@ Returns @racket[#f] if the bitmap is monochrome, @racket[#t] otherwise.
206230 'bmp 'bmp/alpha )
207231 'unknown ]
208232 [bg-color (or/c (is-a?/c color%) #f ) #f ]
209- [complain-on-failure? any/c #f ])
233+ [complain-on-failure? any/c #f ]
234+ [#:save-data-from-file? save-data-from-file? any/c #f ])
210235 boolean?]{
211236
212237Loads a bitmap from a file format that read from @racket[in], unless
@@ -278,7 +303,11 @@ For PNG and BMP loading, if @racket[bg-color] is not @racket[#f], then it is
278303 are both undefined, a platform-specific default is used.
279304
280305After a bitmap is created, @method[bitmap% load-file] can be used
281- only if the bitmap's @tech{backing scale} is @racket[1.0 ].}
306+ only if the bitmap's @tech{backing scale} is @racket[1.0 ].
307+
308+ See @method[bitmap% get-data-from-file] for information on @racket[save-data-from-file?]
309+
310+ @history[#:changed "1.17 " @elem{Added @racket[save-data-from-file?]}]}
282311
283312
284313@defmethod[(make-dc)
0 commit comments