2017-03-08 89 views
2

如何將pict轉換爲其中像素的字節串?racket:圖片字節(像素)

(我的意思是,像素的字節串,這將是在你從渲染PICT得到位圖)

此功能:

#lang racket/base 
(require pict racket/class) 

(define (pict->pixels p)                  
    (define b (pict->bitmap p))                
    (define w (send b get-width))                
    (define h (send b get-height))                
    (define pixbuf (make-bytes (* 4 (inexact->exact (ceiling (* w h))))))      
    (send b get-argb-pixels 0 0 w h pixbuf)             
    pixbuf) 

但有一個簡單的方法?

回答