<html>
  <head>
    <meta content="text/html; charset=ISO-8859-1"
      http-equiv="Content-Type">
  </head>
  <body bgcolor="#FFFFFF" text="#000000">
    Alexander,<br>
    <br>
    Not all bitmaps support all operations.  I've modified your program
    to show the bitmap in the frame.  Hopefully this helps, but I'm not
    sure what you are trying to do.  Let me know if you're still having
    trouble!<br>
    <br>
    Dave<br>
    <br>
    <br>
    <tt>(module ex6 racket/base</tt><tt><br>
    </tt><tt>  </tt><tt><br>
    </tt><tt>  (require srfi/1)</tt><tt><br>
    </tt><tt>  (require srfi/4)</tt><tt><br>
    </tt><tt>  (require srfi/9)</tt><tt><br>
    </tt><tt>  (require racket/class)</tt><tt><br>
    </tt><tt>  (require racket/gui/base)</tt><tt><br>
    </tt><tt>  </tt><tt><br>
    </tt><tt>  (define-record-type game-screen</tt><tt><br>
    </tt><tt>    (make-game-screen width height data)</tt><tt><br>
    </tt><tt>    game-screen?</tt><tt><br>
    </tt><tt>    (width game-screen-width)</tt><tt><br>
    </tt><tt>    (height game-screen-height)</tt><tt><br>
    </tt><tt>    (data game-screen-data))</tt><tt><br>
    </tt><tt>  </tt><tt><br>
    </tt><tt>  (define (initialize-screen)</tt><tt><br>
    </tt><tt>    (let* ((d (make-u8vector (* 4 320 200) 0)))</tt><tt><br>
    </tt><tt>      (do ((i 0 (+ i 4))) ((>= i (* 4 320 200)) #f)</tt><tt><br>
    </tt><tt>        (for-each (lambda (e)</tt><tt><br>
    </tt><tt>                    (u8vector-set! d (+ i (car e)) (cadr
      e)))</tt><tt><br>
    </tt><tt>                  (zip (list 0 1 2 3) (list 200 0 0 255))))</tt><tt><br>
    </tt><tt>      (make-game-screen 320 200 d)))</tt><tt><br>
    </tt><tt>  </tt><tt><br>
    </tt><tt>  (define *the-screen* (initialize-screen))</tt><tt><br>
    </tt><tt>  </tt><tt><br>
    </tt><tt>  (define bitmap (make-bitmap</tt><tt><br>
    </tt><tt>                  (game-screen-width *the-screen*)</tt><tt><br>
    </tt><tt>                  (game-screen-height *the-screen*)))</tt><tt><br>
    </tt><tt>  </tt><tt><br>
    </tt><tt>  (send bitmap set-argb-pixels 0 0</tt><tt><br>
    </tt><tt>        (game-screen-width *the-screen*)</tt><tt><br>
    </tt><tt>        (game-screen-height *the-screen*)</tt><tt><br>
    </tt><tt>        (game-screen-data *the-screen*)</tt><tt><br>
    </tt><tt>        #f #f)</tt><tt><br>
    </tt><tt>  </tt><tt><br>
    </tt><tt>  (define (draw-screen canvas dc)</tt><tt><br>
    </tt><tt>    (send dc draw-bitmap bitmap 0 0))</tt><tt><br>
    </tt><tt>  </tt><tt><br>
    </tt><tt>  (define (main)</tt><tt><br>
    </tt><tt>    (let* ((the-toplevel-frame (new frame% (label
      "Raycaster 3D!") (width 500) (height 500)))</tt><tt><br>
    </tt><tt>           (the-canvas (new canvas% (parent
      the-toplevel-frame) (paint-callback draw-screen))))</tt><tt><br>
    </tt><tt>      (send the-toplevel-frame show #t)))</tt><tt><br>
    </tt><tt>  </tt><tt><br>
    </tt><tt>  (main))</tt><br>
    <br>
    <br>
    <br>
    <div class="moz-cite-prefix">On 06/24/2014 08:28 PM, Alexander
      Shendi wrote:<br>
    </div>
    <blockquote
cite="mid:trinity-92fb42c7-2bc5-4c51-b7ad-19778b302d57-1403656081493@3capp-webde-bs28"
      type="cite">
      <pre wrap="">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" <a class="moz-txt-link-rfc2396E" href="mailto:alexander.shendi@web.de"><alexander.shendi@web.de></a>
An: <a class="moz-txt-link-abbreviated" href="mailto:users@racket-lang.org">users@racket-lang.org</a>
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:
<a class="moz-txt-link-freetext" href="http://lists.racket-lang.org/users">http://lists.racket-lang.org/users</a></pre>
      <br>
      <fieldset class="mimeAttachmentHeader"></fieldset>
      <br>
      <pre wrap="">____________________
  Racket Users list:
  <a class="moz-txt-link-freetext" href="http://lists.racket-lang.org/users">http://lists.racket-lang.org/users</a>
</pre>
    </blockquote>
    <br>
  </body>
</html>