Sign in Join

Live chat for Free Pascal, Lazarus, Delphi and every Pascal programmer.

Mailing lists / lazarus / 2014-11

patch for lazreport (TfrPictureView.getBlob)

3 messages · 2 people · –

Reply by email Subscribe to this list Your subscription

Read-only archive. Use j and k to move between messages.

FreeMan

Why need this modify?
I have over then 1000 rows table, but I have just 3 glyph. not checkbox, but can think same. Integer values can 1-2-3. but user can will see graphic. for showing in lazreport, Have to add TBlobField and have to add glyph to all rows each time, This mean loose time and loose memory.
My patch check "DBImageRead" event is assigned, if DBImageRead is assigned then Blob controls are starting. So, If some used this event and after apply this patch, no need change them codes. I actived, TfrPictureView has no need blob field defined, can define any field of dataset in report, in design.

procedure TForm1.TfrReport1DBImageRead(Sender: TObject; S: TStream; var
GraphExt: string);
begin
   Tmem_Stream.Clear;
   Tmem_Stream.Position := 0;
   GraphExt := 'bmp';
   Tmem_Stream.LoadFromFile('test.bmp');// or what ever code
{or Dataset is work synchronize so I can use dataset's any field
if myQuery.FieldByName('Test_Int').asInteger=1 then
Tmem_Stream.LoadFromFile('test1.bmp');// etc
}
   S.CopyFrom(Tmem_Stream, Tmem_Stream.Size);
   S.Position := 0;// Have to. 'cos getblob not set
end;

I wish add to parameter TfrTField in DBImageRead event, but, when apply patch, have to change code, so I didn't add.
maybe lazreport's chief can add new notify event

-------------- next part --------------
A non-text attachment was scrubbed...
Name: lr_class_TfrPictureView_getBlob.diff
Type: text/x-patch
Size: 1674 bytes
Desc: not available
URL: <http://lists.lazarus.freepascal.org/pipermail/lazarus/attachments/20141130/f0b87997/attachment.bin>

Reply by email

Jesus Reyes
to FreeMan

Because you are getting the image data from a different source than the dataset itself, traditionally you do this in the event OnEnterRect which exists for this kind of situations, see for an example the Thumbnails Report in the lazreport/samples/editor sample, I quote here the relevant part:

procedure TfrmMain.TheReportEnterRect(Memo: TStringList; View: TfrView);
begin
  if (FImageListnil) and (View.Name='thumbnail') then begin
    TFrPictureView(View).Picture.LoadFromFile(FImageList[FImageListIndex]);
    Inc(FImageListIndex);
  end;
end;

In your case you could probably do something like this:

if View is TfrPictureView then begin
  TfrPictureView(View).Picture.LoadFromFile(
    'test' + myQuery.FieldByName('Test_Int').asString+'.bmp')
end;

Which looks more simply than your proposed solution.

Regards.

Jesus Reyes A.

Reply by email

FreeMan
to Jesus Reyes

Thank you Jesus,
No need to my patch.

Jesus Reyes wrote 20 lines
In your case you could probably do something like this: if View is TfrPictureView then begin TfrPictureView(View).Picture.LoadFromFile( 'test' + myQuery.FieldByName('Test_Int').asString+'.bmp') end; Which looks more simply than your proposed solution. Regards. Jesus Reyes A. -- _______________________________________________ Lazarus mailing list http://lists.lazarus.freepascal.org/mailman/listinfo/lazarus

Reply by email