Closed. This question needs details or clarity. It is not currently accepting answers.
Want to improve this question? Add details and clarify the problem by editing this post.
Closed 7 years ago.
Improve this question
I'm trying to encode a stream of image using EncodeBase64 in encddecd.pass that save to the database in a blob field. And retrieve this using decodebase64 in a bytestream that put into a component for showing.
The process good done but image don't show in component.
Here's digest code:
procedure TProcessSave.Execute;
var
i : Integer;
fileStm : TStream;
memStm : TMemoryStream;
encode_plc : string;
begin
for i := 0 to StrList.Count - 1 do
begin
DM.idb_tbl.Append;
DM.idb_tbl.FieldByName('name').AsString := ExtractFileName(StrList.Strings[i]);
try
fileStm := TFileStream.Create(StrList.Strings[i], fmOpenReadWrite);
memStm := TMemoryStream.Create;
filestm.Seek(0, soFromBeginning);
memStm.LoadFromStream(fileStm);
DM.idb_tbl.FieldByName('file').Value := EncodeBase64(memStm.Memory, memStm.Size);
finally
fileStm.Free;
memStm.Free;
end;
DM.idb_tbl.Post;
end;
end;
and for loading:
procedure TLoadBar.Execute;
var
imgStm : TStream;
begin
with DM.idb_qry do
begin
DatabaseName := DM.idb_db.DatabaseName;
SQL.Text := 'SELECT * FROM pics_tbl';
Open;
First;
while not Eof do
begin
try
imgStm :=TBytesStream.Create(DecodeBase64(FieldByName('file').Value));
idx := imgBar_iemv.AppendImage;
imgBar_iemv.SetImageFromStream(idx, imgStm);
imgBar_iemv.ImageID[idx] := id;
finally
imgStm.Free;
end;
Next;
end;
end;
end;
and then I use imgStm for showing picture in a component but images not showing. I'm sure from component. What are your thoughts for encode and decode in my methods? Is another way that is sure for encode and decode for this problem?
Related
Closed. This question is not reproducible or was caused by typos. It is not currently accepting answers.
This question was caused by a typo or a problem that can no longer be reproduced. While similar questions may be on-topic here, this one was resolved in a way less likely to help future readers.
Closed 1 year ago.
Improve this question
I keep getting an error: Identifier expected on the code snippet below.
function InitializeSetup: Boolean;
begin
if (not IsUpgrade()) then
begin
MsgBox(ExpandConstant('{cm:BaseAppMissing}'), mbError, MB_OK);
Result := False;
end;
else
begin
Result := True;
end;
end;
Then when I remove the else part, it works just fine. What is wrong with my code? The begin-end pairing seems okay. What am I missing?
function InitializeSetup: Boolean;
begin
if (not IsUpgrade()) then
begin
MsgBox(ExpandConstant('{cm:BaseAppMissing}'), mbError, MB_OK);
Result := False;
end;
end;
Remove the semicolons after the end keywords inside the if...then...else clause.
Closed. This question is not reproducible or was caused by typos. It is not currently accepting answers.
This question was caused by a typo or a problem that can no longer be reproduced. While similar questions may be on-topic here, this one was resolved in a way less likely to help future readers.
Closed 1 year ago.
Improve this question
DECLARE
num_small number :=20
num_large number :=10
temp NUMBER;
BEGIN
IF num_small > num_large THEN
temp := num_small;
num_small := num_large;
num_large := temp;
END IF;
DBMS_OUTPUT.PUT_LINE('num_small BEFORE = 20, AFTERWARDS = ' || num_small);
DBMS_OUTPUT.PUT_LINE('num_large BEFORE = 10, AFTERWARDS = ' || num_large );
END;
/
Missing semi-colons in declaration section. Should be
DECLARE
num_small NUMBER := 20;
num_large NUMBER := 10;
temp NUMBER;
BEGIN
IF num_small > num_large
THEN
temp := num_small;
num_small := num_large;
num_large := temp;
END IF;
DBMS_OUTPUT.PUT_LINE ('num_small BEFORE = 20, AFTERWARDS = ' || num_small);
DBMS_OUTPUT.PUT_LINE ('num_large BEFORE = 10, AFTERWARDS = ' || num_large);
END;
/
Closed. This question needs details or clarity. It is not currently accepting answers.
Want to improve this question? Add details and clarify the problem by editing this post.
Closed 1 year ago.
Improve this question
In my for loop I used break statement to break loop after some match. But when I compile my code I got error for break:
Error: Illegal expression
Could you help me? I should add some unit?
for i:=0 to length(carsList)-1 do
begin
if numer <> carsList[i].numer then
begin
tmpKw2 := carsList[i].rectangleRotate(carsList[i].angle);
if((polyLine(tmpKw2,linia.p1.x,linia.p1.y,linia.p2.x,linia.p2.y))) then
begin
kolizja := true;
break:=true;
maxV := carsList[i].v;
Break;
end;
end;
end;
The code below works for me:
program Testbreak;
procedure TestBreakInFor;
var
i : Integer;
begin
for i := 0 to 10 do begin
if Odd(i) then
Break;
end;
end;
begin
TestBreakInFor;
readln;
end.
The reason you are getting the "Illegal expression" error is that you are attempting to use Break as if it were a variable (Break := True) when it is not, it is an execution flow-control instruction, like Continue. Omit the := True and it should compile corrrectly.
This question already has an answer here:
Get filename from full path in Pascal
(1 answer)
Closed 6 years ago.
I'm still a beginner using Delphi 7
When I load a VPN config file using TOpenDialog, I put the FileName in a TLabel, but its Caption displays the complete file path, eg:
D:\ConfigVPN\sample.ovpn
How can I display just the file name only?
sample.ovpn
When my application is closed and reopened, how can the Caption be fixed to sample.ovpn?
This is my code:
procedure TForm1.loadClick(Sender: TObject);
begin
if OpenDialog.Execute then begin
config:=OpenDialog.FileName;
Label.Caption:=config;
uhuy;
end;
end;
You can use the ExtractFileName() function in the SysUtils unit:
uses
..., SysUtils;
procedure TForm1.FormCreate(Sender: TObject);
begin
config := ...;
Label.Caption := ExtractFileName(config);
end;
procedure TForm1.loadClick(Sender: TObject);
begin
if OpenDialog.Execute then begin
config := OpenDialog.FileName;
Label.Caption := ExtractFileName(config);
uhuy;
end;
end;
In my Firebird database I have a Blob field that contain a Bitmap. I'll have to load and display in a TImage located on my Form. Subsequently I'll have to save in the same field the image selected by a OpenDialog.
Procedure LoadBitmapFromBlob(Bitmap: TBitmap; Blob: TBlobField);
var
ms, ms2: TMemoryStream;
begin
ms := TMemoryStream.Create;
try
Blob.SaveToStream(ms);
ms.Position := 0;
Bitmap.LoadFromStream(ms);
finally
ms.Free;
end;
end;
example usage
procedure TForm4.Button1Click(Sender: TObject);
var
bmp: TBitmap;
begin
bmp := TBitmap.Create;
try
LoadBitmapFromBlob(bmp, TBlobField(Dataset.FieldByName('Image')));
Image1.Picture.Assign(bmp);
bmp.SaveToFile(OpenDialog.FileName);
finally
bmp.Free;
end;
end;