Icon View Incident Report

Serious Serious
Reported By: Graham Wood
Reported On: 3/12/1999
For: Version 1.13 Build 1
# 330 Loading Bitmaps into Graphic Fields Causes Read Error

I am having a problem with DBISAM 1.12 loading a picture into a field of the 'Graphic' type. If I use the DBISAM Database System program to load the Graphics, I can get three or four loaded but then loading
the next picture (all just small bitmaps) gives a read error. Rebuilding the table has no effect on the corrupted graphics field which cannot be viewed by either a DMImage component or by the DBISAM Database System grid being double clicked. I can only remedy this by deleting the entire record (ouch).
In my program, if I try to load a graphic into a standard DBImage component using the following code, I get a picture in the DBImage after loading, then I get a read error.

procedure TFormMain.ButtonLoadPictureClick(Sender: TObject);
begin
  with OpenPictureDialog do begin
    DefaultExt := 'BMP';
    Filter := GraphicFilter(TGraphic);
    if Execute then begin
      if DataModuleMain.DataSourcePlant.AutoEdit
        then DataModuleMain.DataSourcePlant.Edit;
      DBImage.Picture.LoadFromFile(FileName);
      UpdatePictureField;
    end;
  end;
end;

procedure TFormMain.UpdatePictureField;
var
  Tmp: TBitmap;
begin
  if (DBImage.Picture.Graphic <> nil) and
    not (DBImage.Picture.Graphic.Empty) then
  begin
    if not (DBImage.Picture.Graphic is TBitmap) then begin
      Tmp := TBitmap.Create;
      try
        Tmp.Assign(DBImage.Picture.Graphic);
        DBImage.Picture.Assign(Tmp);
      finally
        Tmp.Free;
      end;
    end;
  end;
end;

procedure TFormMain.PictureMenuClick(Sender: TObject);
begin
  case Integer(TMenuItem(Sender).Tag) of
    1: DBImage.Perform(WM_CUT, 0, 0);
    2: DBImage.Perform(WM_COPY, 0, 0);
    3: DBImage.Perform(WM_PASTE, 0, 0);
    4: begin
         if DataModuleMain.DataSourcePlant.AutoEdit
           then DataModuleMain.DataSourcePlant.Edit;
         DBImage.Picture.Graphic := nil;
         UpdatePictureField;
       end;
  end;
end;




procedure TFormMain.ButtonSaveAsClick(Sender: TObject);
begin
  with SavePictureDialog do begin
    if (DBImage.Picture.Graphic <> nil) and
      not (DBImage.Picture.Graphic.Empty) then
    begin
      DefaultExt := 
GraphicExtension(TGraphicClass(DBImage.Picture.Graphic.ClassType));
      Filter := 
GraphicFilter(TGraphicClass(DBImage.Picture.Graphic.ClassType));
    end
    else begin
      DefaultExt := 'BMP';
      Filter := GraphicFilter(TGraphic);
    end;
    if Execute then DBImage.Picture.SaveToFile(FileName);
  end;
end;



Comments Comments
Problem was with a change in 1.13 that caused the size to be truncated in certain circumstances when loading data into BLOBs.


Resolution Resolution
Fixed Problem on 3/16/1999 in version 1.14 build 1
Image