Top = 312
end
object FDTable1: TFDTable
- Active = True
- BeforeInsert = FDTable1BeforeInsert
AfterInsert = FDTable1AfterInsert
AfterPost = FDTable1AfterPost
IndexFieldNames = 'id'
object FDTable1id: TFDAutoIncField
FieldName = 'id'
Origin = 'id'
- ReadOnly = True
+ ProviderFlags = [pfInUpdate, pfInWhere, pfInKey]
Required = True
- AutoIncrementSeed = 0
+ AutoIncrementSeed = 1
AutoIncrementStep = 1
+ IdentityInsert = True
end
object FDTable1name: TWideStringField
FieldName = 'name'
OutputConverters = <>
Left = 20
Top = 5
- object LinkPropertyToFieldBitmap: TLinkPropertyToField
- Category = #12463#12452#12483#12463' '#12496#12452#12531#12487#12451#12531#12464
- DataSource = BindSourceDB1
- FieldName = 'source'
- Component = Image1
- ComponentProperty = 'Bitmap'
- end
object LinkControlToField1: TLinkControlToField
Category = #12463#12452#12483#12463' '#12496#12452#12531#12487#12451#12531#12464
DataSource = BindSourceDB1
Component = Label1
ComponentProperty = 'Text'
end
+ object LinkPropertyToFieldBitmap: TLinkPropertyToField
+ Category = #12463#12452#12483#12463' '#12496#12452#12531#12487#12451#12531#12464
+ DataSource = BindSourceDB1
+ FieldName = 'source'
+ Component = Image1
+ ComponentProperty = 'Bitmap'
+ end
end
object FDGUIxWaitCursor1: TFDGUIxWaitCursor
Provider = 'FMX'
System.SysUtils, System.Types, System.UITypes, System.Classes,
System.Variants,
FMX.Types, FMX.Controls, FMX.Forms, FMX.Dialogs, FMX.Ani, FMX.Layouts,
- FMX.Gestures,
+ FMX.Gestures, FMX.Graphics, FMX.Surfaces,
FireDAC.Stan.Intf, FireDAC.Stan.Option, FireDAC.Stan.Param,
FireDAC.Stan.Error, FireDAC.DatS, FireDAC.Phys.Intf, FireDAC.DApt.Intf,
FireDAC.Stan.Async, FireDAC.DApt, FireDAC.UI.Intf, FireDAC.Stan.Def,
FDGUIxWaitCursor1: TFDGUIxWaitCursor;
BindSourceDB1: TBindSourceDB;
NavigatorBindSourceDB12: TBindNavigator;
- LinkPropertyToFieldBitmap: TLinkPropertyToField;
LinkControlToField1: TLinkControlToField;
Button1: TButton;
OpenDialog1: TOpenDialog;
FDTable1id: TFDAutoIncField;
FDTable1name: TWideStringField;
FDTable1source: TBlobField;
+ LinkPropertyToFieldBitmap: TLinkPropertyToField;
procedure Button1Click(Sender: TObject);
- procedure FDTable1BeforeInsert(DataSet: TDataSet);
procedure FDTable1AfterInsert(DataSet: TDataSet);
procedure FormCreate(Sender: TObject);
procedure FDTable1AfterPost(DataSet: TDataSet);
private
- pos: integer;
{ private \90é\8c¾ }
public
{ public \90é\8c¾ }
procedure TForm2.Button1Click(Sender: TObject);
var
s: TStream;
+ bmp: TBitmapSurface;
+ pm: TBitmapCodecSaveParams;
begin
if OpenDialog1.Execute = true then
begin
- Image1.Bitmap.LoadFromFile(OpenDialog1.FileName);
- s := FDTable1.CreateBlobStream(FDTable1.FieldByName('source'), bmWrite);
+ FDTable1.Edit;
+ bmp:=TBitmapSurface.Create;
try
- Image1.Bitmap.SaveToStream(s);
+ s := FDTable1.CreateBlobStream(FDTable1.FieldByName('source'), bmWrite);
+ Image1.Bitmap.LoadFromFile(OpenDialog1.FileName);
+ bmp.Assign(Image1.Bitmap);
+ pm.Quality:=100;
+ TBitmapCodecManager.SaveToStream(s,bmp,'.jpg',@pm);
finally
s.Free;
+ bmp.Free;
end;
+ FDTable1.Post;
end;
end;
procedure TForm2.FDTable1AfterInsert(DataSet: TDataSet);
begin
- FDTable1.FieldByName('id').AsInteger := pos;
- FDTable1.FieldByName('name').AsString := 'slide' + pos.ToString + '.jpg';
+ FDTable1.FieldByName('name').AsString := 'slide' + FDTable1.FieldByName('id')
+ .AsString + '.jpg';
end;
procedure TForm2.FDTable1AfterPost(DataSet: TDataSet);
FDTable1.Refresh;
end;
-procedure TForm2.FDTable1BeforeInsert(DataSet: TDataSet);
-begin
- FDTable1.Last;
- pos := FDTable1.FieldByName('id').AsInteger + 1;
-end;
-
procedure TForm2.FormCreate(Sender: TObject);
begin
if FDTable1.Exists = false then
- begin
FDTable1.CreateTable;
- FDTable1.Open;
- end;
+ FDTable1.Open;
FDTable1.Refresh;
end;