Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- function LoadPicture(AFilePath: PAnsiChar; ABlob: PBlob): PBlob; cdecl;
- var
- img: TJPEGImage;
- APathStr: AnsiString;
- AStream: TMemoryStream;
- AOutPutStream: TStringStream;
- ALogFile: TextFile;
- tmpInteger: Integer;
- ARes: PAnsiChar;
- begin
- AssignFile(ALogFile, 'C:TesteDll.txt');
- Rewrite(ALogFile);
- img := TJPEGImage.Create;
- AStream := TMemoryStream.Create;
- AOutPutStream := TStringStream.Create('');
- try
- Writeln(ALogFile, AFilePath);
- try
- APathStr := Trim(string(AFilePath));
- if FileExists(APathStr) then begin
- img.LoadFromFile(APathStr);
- img.SaveToStream(AStream);
- AStream.Position := 0;
- Writeln(ALogFile, AStream.Size);
- EncodeStream(AStream, AOutPutStream);
- end;
- AOutPutStream.Position := 0;
- tmpInteger := Length(AOutPutStream.DataString);
- Writeln(ALogFile, tmpInteger+1);
- ARes := ib_util_malloc((tmpInteger+1));
- StrPLCopy(ARes, AOutPutStream.DataString, tmpInteger);
- Writeln(ALogFile, ARes);
- Writeln(ALogFile, StrLen(ARes));
- ABlob^.PutSegment(ABlob^.BlobHandle, ARes, StrLen(ARes));
- Result := ABlob;
- except
- on e: Exception do
- Writeln(ALogFile, e.Message);
- end;
- finally
- CloseFile(ALogFile);
- FreeAndNil(img);
- FreeAndNil(AOutPutStream);
- FreeAndNil(AStream);
- end;
- end;
Add Comment
Please, Sign In to add comment