unsigned char array -> buffer

Henri Schomaecker hs at byteconcepts.de
Mon Oct 18 19:02:45 CEST 2004


Hi Diez,

oh, I thought I made it clear: The data is a jpg image.
Let me try to explain it like that:

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.

I hope it's clear now and would be very glad, If maybe you could help me.
Again, many thanks in advance,
    yours Henri


Diez B. Roggisch wrote:

> Henri Schomaecker wrote:
>> as I already wrote, I'm trying to get image binary data into a var
>> holding an unsigned char string and then print it directly to the
>> browser. I now already did some tries with an array and now found the
>> buffer() function. - I thought I would have the solution now and also
>> changed stdout to O_BINARY, but still I don't get the data right:
>> 
>> 8<--------8<--------8<--------8<--------8<--------
>> 
>> imgObj = win32com.client.Dispatch("mine.imgsender")
>> myImgData = buffer(imgObj.getImgData())
>> 
>> msvcrt.setmode(sys.stdout.fileno(), os.O_BINARY)
>> sys.stdout.write(myImgData)
>> 
>> 8<--------8<--------8<--------8<--------8<--------
>> 
>> I'm really lost and would be very thankful if someone could help me with
>> that.
> 
> That snipplet of code is totally useless, as none of us has your custom
> mine.imgsender lying around his harddisk, so we can't possibly know what
> data you get, let alone what data you want.
> 
> So if you provided us with the actual data that is returned by getImgData
> we might be able to help.
> 

-- 
| Henri Schomäcker - BYTECONCEPTS, VIRTUAL HOMES
|     Datendesign für Internet und Intranet
|         http://www.byteconcepts.de
|         http://www.virtual-homes.de



More information about the Python-list mailing list