unsigned char array -> buffer

Diez B. Roggisch deetsNOSPAM at web.de
Mon Oct 18 13:59:01 EDT 2004


Hi,
 
> I create a com object, which loads a jpg image and then I request that
> image from the com object with the method getImgData().
> As answer to getImageData(), the com object returns a SafeArray of
> unsigned char (Bytes).
> 
> My problem (no problem with asp and perl, same with php) is, that I would
> like to read the imagedata directly into a string of unsigned chars and
> then print it to the user agent (webbrowser) in binary mode.
> 
> So, it would not really make sense to print the imagedata here ;-) - Sorry
> for that confusion.

It will - as one can see what you actually get, instead of what you _want_
to get. AFAIK win32 converts variants to appropriate python types, with
arrays returned as lists - so if things work as documented, you shold get
something like this:

l = ["a", "$", ...]

Making that a (binary) string should be a simple matter of 

l.join("")

So I'd like to know what you really get- of cours the first few lines are
sufficient, no need to post a 100kb jpeg binary image.


-- 
Regards,

Diez B. Roggisch



More information about the Python-list mailing list