daily pastebin goal
29%
SHARE
TWEET

Untitled

a guest Mar 13th, 2018 53 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. function LoadPicture(AFilePath: PAnsiChar; ABlob: PBlob): PBlob; cdecl;
  2. var
  3.   img: TJPEGImage;
  4.   APathStr: AnsiString;
  5.   AStream: TMemoryStream;
  6.   AOutPutStream: TStringStream;
  7.   ALogFile: TextFile;
  8.   tmpInteger: Integer;
  9.   ARes: PAnsiChar;
  10. begin
  11.   AssignFile(ALogFile, 'C:TesteDll.txt');
  12.   Rewrite(ALogFile);
  13.   img           := TJPEGImage.Create;
  14.   AStream       := TMemoryStream.Create;
  15.   AOutPutStream := TStringStream.Create('');
  16.   try
  17.     Writeln(ALogFile, AFilePath);
  18.     try
  19.       APathStr := Trim(string(AFilePath));
  20.       if FileExists(APathStr) then begin
  21.         img.LoadFromFile(APathStr);
  22.         img.SaveToStream(AStream);
  23.         AStream.Position := 0;
  24.         Writeln(ALogFile, AStream.Size);
  25.         EncodeStream(AStream, AOutPutStream);
  26.       end;
  27.       AOutPutStream.Position := 0;
  28.       tmpInteger := Length(AOutPutStream.DataString);
  29.       Writeln(ALogFile, tmpInteger+1);
  30.       ARes       := ib_util_malloc((tmpInteger+1));
  31.       StrPLCopy(ARes, AOutPutStream.DataString, tmpInteger);
  32.       Writeln(ALogFile, ARes);
  33.       Writeln(ALogFile, StrLen(ARes));
  34.       ABlob^.PutSegment(ABlob^.BlobHandle, ARes, StrLen(ARes));
  35.       Result := ABlob;
  36.     except
  37.       on e: Exception do
  38.         Writeln(ALogFile, e.Message);
  39.     end;
  40.   finally
  41.     CloseFile(ALogFile);
  42.     FreeAndNil(img);
  43.     FreeAndNil(AOutPutStream);
  44.     FreeAndNil(AStream);
  45.   end;
  46. end;
RAW Paste Data
We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the Cookies Policy. OK, I Understand
 
Top