F
fux
Unregistered / Unconfirmed
GUEST, unregistred user!
Has anyone used the olympus sdk to download a picture with delphi.
I got some sample code, but it does not work. I think it is something
to do with the olevariant. Can anyone help?
var
OleBuffer: OleVariant;
PicNum: Integer;
PicSize: Integer;
begin
Jam1.Connect;
PicNum := Jam1.propPicCount;
Label2.Caption := IntToStr(PicNum);
Jam1.propCurrentPicture := PicNum;
PicSize := Jam1.propPicSize;
Label4.Caption := IntToStr(PicSize);
Application.ProcessMessages;
OleBuffer := VarArrayCreate([1,PicSize],varByte);
Jam1.GetPicture(PicSize,OleBuffer);
VariantToFile('c:/project1.jpg',OleBuffer);
Application.ProcessMessages;
Jam1.DisConnect;
Close;
procedure TForm1.VariantToFile(FileName: String; var AVariant:
OleVariant);
var
AStream: TFileStream;
MyBuffer: PUCHAR;
Size: Integer;
begin
AStream:=TFileStream.create(FileName,fmCreate);
try
aStream.Position := 0;// Seek(0, soFromBeginning);
Size:=VarArrayHighBound(AVariant,1);//+VarArrayLowBound(AVariant,1);
MyBuffer:=VarArrayLock(AVariant);
AStream.WriteBuffer(MyBuffer^,Size);
Application.ProcessMessages;
VarArrayUnlock(AVariant);
finally
AStream.Free;
end;
end;
I got some sample code, but it does not work. I think it is something
to do with the olevariant. Can anyone help?
var
OleBuffer: OleVariant;
PicNum: Integer;
PicSize: Integer;
begin
Jam1.Connect;
PicNum := Jam1.propPicCount;
Label2.Caption := IntToStr(PicNum);
Jam1.propCurrentPicture := PicNum;
PicSize := Jam1.propPicSize;
Label4.Caption := IntToStr(PicSize);
Application.ProcessMessages;
OleBuffer := VarArrayCreate([1,PicSize],varByte);
Jam1.GetPicture(PicSize,OleBuffer);
VariantToFile('c:/project1.jpg',OleBuffer);
Application.ProcessMessages;
Jam1.DisConnect;
Close;
procedure TForm1.VariantToFile(FileName: String; var AVariant:
OleVariant);
var
AStream: TFileStream;
MyBuffer: PUCHAR;
Size: Integer;
begin
AStream:=TFileStream.create(FileName,fmCreate);
try
aStream.Position := 0;// Seek(0, soFromBeginning);
Size:=VarArrayHighBound(AVariant,1);//+VarArrayLowBound(AVariant,1);
MyBuffer:=VarArrayLock(AVariant);
AStream.WriteBuffer(MyBuffer^,Size);
Application.ProcessMessages;
VarArrayUnlock(AVariant);
finally
AStream.Free;
end;
end;