Want to protect your cyber security and still get fast solutions? Ask a secure question today.Go Premium

x
  • Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 301
  • Last Modified:

COM, IPICTURE, PICTURE, how to pass graphics from COM?

hi. I'd like to create a COM/MTS object that can pass a JPEG picture or stream to ASP.
I hear many things about IStream but I can't find any IStream in the 'Type Library' window.
Please Help. Thanks
0
zzzxtreme
Asked:
zzzxtreme
  • 2
1 Solution
 
Lee_NoverCommented:
asp can use an IPicture interface .. well VB does so I'm guessing asp can as well :)
so .. simply use:
GetOlePicture(MyDelphiPicture, OutputIPicture)
if the procedure fails OutputIPicture is nil
it's in the AxCtrls unit
from the help:
The Picture parameter is a pointer to the native TPicture. This can be the Picture property of a VCL control.  The OLE picture is returned in the OlePicture parameter. The resulting OLE picture object is a direct connection to the native VCL picture, so changing the OLE picture's properties will change the TPicture's properties, and vice-versa.

if you still want to go with IStream then this could help:
uses classes, jpeg, activex;

function GetJPEGStream: IStream;
var jpg: TJPEGImage;
    ms: TMemoryStream;
    sa: TStreamAdapter;
begin
     jpg:=TJPEGImage.Create;
     try
        ms:=TMemoryStream.Create;
        try
           jpg.SaveToStream(ms);
           ms.Seek(0, soFromBeginning);
           sa:=TStreamAdapter.Create(ms);
           try
              Result:=sa;
           finally
              sa.Free;
           end;
        finally
           ms.Free;
        end;
     finally
        jpg.Free;
     end;
end;

haven't worked with this so I don't know how the memory is managed and how to free the streams correctly
check that out
0
 
Lee_NoverCommented:
ah . in the GetJPEGStream function .. ofcourse after creating the jpeg you load it from somwhere :)
a file most probably
0
 
MrGhostCommented:
you can't use istream if you going to use out of process communication you need to somthing else variant or safearray ...
0

Featured Post

Industry Leaders: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

  • 2
Tackle projects and never again get stuck behind a technical roadblock.
Join Now