I am doing some lower level work with saving bitmap images to a file using scanline. After reading a LongInt from the file (as the program was already developed this way), I try simply assigning this value to an Integer within an object. This integer is actually a published property of the object, which calls a SetValue procedure, where I assign it (and other stuff). My object is for sure created just 4 lines of code before I try this, and cannot figure it out.
Here's a snippet of my code:
JD Solutions
Here's a snippet of my code:
Code:
var
TID: LongInt; //Tried as integer too
begin
.........
bmp:= TBitmap.Create; {color 24 bit xor map holder}
try
bmp.height:= IHeight;
bmp.width:= IWidth;
bmp.pixelformat:= pf24bit;
for i:= 0 to ImageCount - 1 do begin
RowLength:= (IWidth * 24) div 8;
T:= TJDThumbnail.Create; //CREATING THE OBJECT
T.ID:= 0;
BlockRead(f, TID, 12, amt); //READING LONGINT VALUE FROM FILE
if amt <> 12 then EM:= EM + 'ID - File Format Incorrect'+#10;
T.ID:= TID; //THIS IS WHERE IT'S ASSIGNED TO THE INTEGER (SEE BELOW)
for y:= 0 to IHeight - 1 do begin
pb:= bmp.ScanLine[y]; {get ^ address of first byte on row}
BlockRead(f, pb^, RowLength, amt);
if amt <> RowLength then
EM:= EM + 'Read incorrect amount of line data ('+
IntToStr(amt)+'/'+IntToStr(RowLength)+')' + #10;
end;
T.Bitmap.Assign(bmp);
fThumbs.AddObject(IntToStr(T.ID), T);
end;
finally
bmp.free;
end;
..........
TJDThumbnail = class(TPersistent)
private
fID: Integer; //ACTUAL VARIABLE OF INTEGER
fBitmap: TBitmap;
procedure SetID(Value: Integer);
public
constructor Create;
destructor Destroy; override;
property Bitmap: TBitmap read fBitmap;
published
property ID: Integer read fID write SetID; //PROPERTY OF INTEGER
end;
..........
procedure TJDThumbnail.SetID(Value: Integer);
begin
fID:= Value; //ACTUAL ASSIGNING OF LONGINT TO INTEGER
end;
JD Solutions