Board index » delphi » IPicture : CS to SS

IPicture : CS to SS

My problem is about transmitting a picture from client-side to the
server-side.
e.g. for to build up a menu tree and to set the tmenuitems bitmaps
How can I transmit an tpicture from the client to the server? Every solution
using IPictureDisp hasn't worked... so what am I doing wrong ?
Any hints for me?

Greetings form Germany,
Michael Speer

 

Re:IPicture : CS to SS


I would probably just make a routine to put the picture into a variant array
of bytes. There's a bunch of ways to do that but I would probably use the
SaveToStream into a TMemoryStream and then copy the MemoryStream into a
pointer. Here's some pseudo code:

server:
procedure foo1(Pic: Variant; Size: Integer);

client:
procedure foo2(Bitmap: TBitMap);
var
  Pic: variant;
  Size: Integer;
  pPic: Pointer;
  MemoryStream: TMemoryStream;
begin
  MemoryStream := TMemoryStream.Create;
  Bitmap.SaveToStream(MemoryStream);
  Size := MemoryStream.Size;

  Pic ;= varArrayCreate([0..Size], varByte);
  pPic := VarArrayLock(Pic);

  MemoryStream.Seek(soFromBeginning, 0);
  MemoryStream.ReadBuffer(pPic^, Size);
  MemoryStream.Free;

  VarArrayUnlokc(pPic);
  Server.foo1(Pic, Size);

end;

Regards,

Joel Milne
SoftMosis Consulting Inc.
www.softmosis.ca

Quote
Michael Speer <Michael.Sp...@TrueTec.de> wrote in message

news:7dtaak$c1u6@forums.borland.com...
Quote
>My problem is about transmitting a picture from client-side to the
>server-side.
>e.g. for to build up a menu tree and to set the tmenuitems bitmaps
>How can I transmit an tpicture from the client to the server? Every
solution
>using IPictureDisp hasn't worked... so what am I doing wrong ?
>Any hints for me?

>Greetings form Germany,
>Michael Speer

Re:IPicture : CS to SS


This line:

Quote
>  Pic ;= varArrayCreate([0..Size], varByte);

should read

  Pic := varArrayCreate([0..Size-1], varByte);

Other Threads