Henri Schomäcker
2004-03-03 10:15:26 UTC
Hi folks,
I'm trying to write a ActiveX com-component which has a function which
should return jpeg-image-data. Until now, I wanted to return it as a BSTR.
Inside the com component, I'm using a class of mine which returns
the jpeg-image-data in a char* string.
I tested the class in a little exe testproject, which directly returns the
image to the browser when used as a cgi-application.
This works fine using...
8<--------8<--------8<--------8<--------8<--------
printf("Content-type: image/jpeg\r\n\r\n");
setmode(fileno(stdout), _O_BINARY);
fwrite(imgBuffer, imgSize, 1, stdout);
8<--------8<--------8<--------8<--------8<--------
In my com-component function getImage() I tried using...
8<--------8<--------8<--------8<--------8<--------
CComBSTR temp(imgBuffer);
*retstr = temp.Detach();
8<--------8<--------8<--------8<--------8<--------
...which returns a BSTR containing the image-data.
The Problem is, it's not in binary-mode now, gets formated and the image
doesn't display properly.
How can I replace the second snippet by some code to return imgBuffer in
binary-mode in a BSTR or other appropriate type which can then be returned
by the com-component? I found an article about a BSTR-wrapper-class, but
don't know if such a variable isn't formated again when I apppend it to
CComBSTR.
The goal is to easy access the image data with any scripting-language like
this (in vbscript, for axample):
8<--------8<--------8<--------8<--------8<--------
Response.ContentType = "image/jpeg"
Dim strImage
Dim objImage
Set objImage = Server.CreateObject("mytools.imgServer")
strImage = objImage.getImage()
Set objImage = Nothing
Response.BinaryWrite(strImage)
8<--------8<--------8<--------8<--------8<--------
Many thanks in advance,
yours Henri
I'm trying to write a ActiveX com-component which has a function which
should return jpeg-image-data. Until now, I wanted to return it as a BSTR.
Inside the com component, I'm using a class of mine which returns
the jpeg-image-data in a char* string.
I tested the class in a little exe testproject, which directly returns the
image to the browser when used as a cgi-application.
This works fine using...
8<--------8<--------8<--------8<--------8<--------
printf("Content-type: image/jpeg\r\n\r\n");
setmode(fileno(stdout), _O_BINARY);
fwrite(imgBuffer, imgSize, 1, stdout);
8<--------8<--------8<--------8<--------8<--------
In my com-component function getImage() I tried using...
8<--------8<--------8<--------8<--------8<--------
CComBSTR temp(imgBuffer);
*retstr = temp.Detach();
8<--------8<--------8<--------8<--------8<--------
...which returns a BSTR containing the image-data.
The Problem is, it's not in binary-mode now, gets formated and the image
doesn't display properly.
How can I replace the second snippet by some code to return imgBuffer in
binary-mode in a BSTR or other appropriate type which can then be returned
by the com-component? I found an article about a BSTR-wrapper-class, but
don't know if such a variable isn't formated again when I apppend it to
CComBSTR.
The goal is to easy access the image data with any scripting-language like
this (in vbscript, for axample):
8<--------8<--------8<--------8<--------8<--------
Response.ContentType = "image/jpeg"
Dim strImage
Dim objImage
Set objImage = Server.CreateObject("mytools.imgServer")
strImage = objImage.getImage()
Set objImage = Nothing
Response.BinaryWrite(strImage)
8<--------8<--------8<--------8<--------8<--------
Many thanks in advance,
yours Henri