[racket] racket/gui: Problem displaying bitmap data
Hello all,
I'm attaching (and including inline) a simple test-case that can be run via:
racket -t ex6.rkt
Thanks in advance for your help.
Best Regards,
Alexander
----------------------------------------------------------------------------------------------
(module ex6 racket/base
(require srfi/1)
(require srfi/4)
(require srfi/9)
(require racket/class)
(require racket/gui/base)
(define-record-type game-screen
(make-game-screen width height data)
game-screen?
(width game-screen-width)
(height game-screen-height)
(data game-screen-data))
(define (initialize-screen)
(let* ((d (make-u8vector (* 4 320 200) 0)))
(do ((i 0 (+ i 4))) ((>= i (* 4 320 200)) #f)
(for-each (lambda (e)
(u8vector-set! d (+ i (car e)) (cadr e)))
(zip (list 0 1 2 3) (list 200 0 0 255))))
(make-game-screen 320 200 d)))
(define *the-screen* (initialize-screen))
(define (main)
(let* ((the-toplevel-frame (new frame% (label "Raycaster 3D!")))
(the-canvas (new canvas% (parent the-toplevel-frame)))
(the-canvas-bitmap (send the-canvas make-bitmap
(game-screen-width *the-screen*)
(game-screen-height *the-screen*)))
(the-canvas-bitmap-dc (new bitmap-dc% (bitmap the-canvas-bitmap))))
(send the-canvas-bitmap-dc set-argb-pixels 0 0
(game-screen-width *the-screen*)
(game-screen-height *the-screen*)
(game-screen-data *the-screen*)
#f #f)
(send the-toplevel-frame show #t)))
(main))
----------------------------------------------------------------------------------------------
Gesendet: Dienstag, 24. Juni 2014 um 20:25 Uhr
Von: "Alexander Shendi" <alexander.shendi at web.de>
An: users at racket-lang.org
Betreff: [racket] racket/gui: Problem displaying bitmap data
Dear list,
I am trying to display bitmap data that I have written into a SRFI-4 u8vector (that I believe maps to a Racket
bytevector). The bitmap data is in RGBA format. Now I am trying to display the bitmap data in a window.
Please see the relevant part of my program below:
(define (main)
(let* ((the-toplevel-frame (new frame% (label "Raycaster 3D!")))
(the-canvas (new canvas% (parent the-toplevel-frame)))
(the-canvas-bitmap (send the-canvas make-bitmap
(game-screen-width *the-screen*)
(game-screen-height *the-screen*)))
(the-canvas-bitmap-dc (new bitmap-dc% (bitmap the-canvas-bitmap))))
(for-each (lambda (e) (apply vline e)) (raycast-all *game-map*)) ;; Application logic :)
(send the-canvas-bitmap-dc set-argb-pixels 0 0
(game-screen-width *the-screen*)
(game-screen-height *the-screen*)
(game-screen-data *the-screen*)
#f #f)
(send the-toplevel-frame show #t)))
However this results in the error message:
$ racket -t game6.rkt
[Debug output of program snipped] ...
set-argb-pixels in bitmap%: not available in a canvas-compatible bitmap: (object:x11-bitmap% ...)
context...:
/usr/local/share/racket/pkgs/draw-lib/racket/draw/private/bitmap.rkt:776:4: core404
/home/alexshendi/sources/racket/game/game6.rkt:366:2: main
/home/alexshendi/sources/racket/game/game6.rkt: [running body]
Operating System: Linux x86_64 (Ubuntu 14.04)
Racket Version: 6.0.1 (Release)
Can anyone help me do it the correct way? Many thanks in advance.
Best Regards,
Alexander
~
~
~
~
~
~
~
~
~
~
~
~
____________________
Racket Users list:
http://lists.racket-lang.org/users
-------------- next part --------------
A non-text attachment was scrubbed...
Name: ex6.rkt
Type: application/octet-stream
Size: 1471 bytes
Desc: not available
URL: <http://lists.racket-lang.org/users/archive/attachments/20140625/e7e631a1/attachment.obj>