ViewVC Help
View File | Revision Log | View Changeset | Root Listing
root/Oni2/oup/current/Global/OniImgClass.pas
(Generate patch)

Comparing oup/current/Global/OniImgClass.pas (file contents):
Revision 194 by alloc, Sat May 26 18:26:48 2007 UTC vs.
Revision 244 by alloc, Fri Aug 17 21:09:51 2007 UTC

# Line 29 | Line 29 | type
29  
30      constructor Create;
31      procedure Free;
32    function Load(ConnectionID, FileID: Integer): Boolean;
33    function LoadFromPSpc(ConnectionID, FileID: Integer): Boolean;
34    function LoadFromTXMP(ConnectionID, FileID: Integer): Boolean;
35    function LoadFromTXMB(ConnectionID, FileID: Integer): Boolean;
32  
33 <    procedure SaveDataToStream(MipMaps: Boolean; var Target: TStream);
33 >    function GetImageSize(MipMaps: Boolean): Integer;
34  
35      function LoadFromFile(filename: String): Boolean;
36      function WriteToFile(filename: String): Boolean;
37 <
37 >    procedure SaveDataToStream(MipMaps: Boolean; var Target: TStream);
38      procedure DrawOnCanvas(Canvas: TCanvas; Index: Integer);
39 <    function GetImageSize(MipMaps: Boolean): Integer;
39 >
40 >    function Load(ConnectionID, FileID: Integer): Boolean;
41 >    function LoadFromTXMP(ConnectionID, FileID: Integer): Boolean;
42 >    function LoadFromTXMB(ConnectionID, FileID: Integer): Boolean;
43 >    function LoadFromPSpc(ConnectionID, FileID: Integer): Boolean;
44    published
45    end;
46  
47  
48   implementation
49  
50 //uses Functions;
50   uses Img_DDSTypes, ImagingComponents;
51  
52  
54 procedure TOniImage.DrawOnCanvas(Canvas: TCanvas; Index: Integer);
55 var
56  singleimg: TImageData;
57  rect: TRect;
58 begin
59  InitImage(singleimg);
60  CloneImage(FImages[Index-1], singleimg);
61  ConvertImage(singleimg, ifX8R8G8B8);
62  rect.Left := 0;
63  rect.Top := 0;
64  rect.Right := singleimg.Width - 1;
65  rect.Bottom := singleimg.Height - 1;
66  Canvas.Brush.Color := $C8D0D4;
67  Canvas.FillRect(Canvas.ClipRect);
68  DisplayImageData(Canvas, rect, singleimg, rect);
69  FreeImage(singleimg);
70 end;
71
72
73
74 constructor TOniImage.Create;
75 begin
76 end;
77
78
79
80 procedure TOniImage.Free;
81 begin
82  FreeImagesInArray(FImages);
83 end;
84
85
86
87
53   function TOniImage.GetImage(MipGen: Integer): TImageData;
54   begin
55    if MipGen <= Length(FImages) then
# Line 95 | Line 60 | begin
60   end;
61  
62  
98
63   function TOniImage.GetWidth(MipGen: Integer): Integer;
64   begin
65    if MipGen <= Length(FImages) then
# Line 145 | Line 109 | begin
109   end;
110  
111  
112 < function TOniImage.Load(ConnectionID, FileID: Integer): Boolean;
112 >
113 >
114 > constructor TOniImage.Create;
115 > begin
116 > end;
117 >
118 > procedure TOniImage.Free;
119 > begin
120 >  FreeImagesInArray(FImages);
121 > end;
122 >
123 >
124 >
125 >
126 > function TOniImage.GetImageSize(MipMaps: Boolean): Integer;
127   var
128 <  FileInfo: TFileInfo;
128 >  i: Integer;
129   begin
130 <  FileInfo := ConManager.Connection[ConnectionID].GetFileInfo(fileid);
131 <  if FileInfo.Extension = 'PSpc' then
132 <    Result := LoadFromPSpc(ConnectionID, fileid)
133 <  else if FileInfo.Extension = 'TXMB' then
134 <    Result := LoadFromTXMB(ConnectionID, fileid)
135 <  else if FileInfo.Extension = 'TXMP' then
136 <    Result := LoadFromTXMP(ConnectionID, fileid)
130 >  if Length(FImages) > 0 then
131 >  begin
132 >    Result := FImages[0].Size;
133 >    if mipmaps then
134 >      for i := 1 to High(FImages) do
135 >        Result := Result + FImages[i].Size;
136 >  end
137    else
138 <    Result := False;
138 >    Result := -1;
139   end;
140  
141  
142  
143  
144 < function TOniImage.LoadFromPSpc(ConnectionID, FileID: Integer): Boolean;
145 < type
146 <  TPoint = packed record
147 <    X, Y: Word;
148 <  end;
144 > function TOniImage.LoadFromFile(filename: String): Boolean;
145 > begin
146 >  Result := LoadMultiImageFromFile(filename, FImages);
147 >  if not Result then
148 >    ShowMessage('Couldn''t load image file');
149 > end;
150  
172  TPSpc = packed record
173    p1:   array[0..8] of TPoint;
174    p2:   array[0..8] of TPoint;
175    TXMP: Integer;
176  end;
151  
152 <  TPart = packed record
153 <    x_txmp, y_txmp: Word;
154 <    x_pspc, y_pspc: Word;
155 <    w, h:    Word;
156 <    imgdata: TByteData;
157 <    used:    Boolean;
158 <  end;
159 < const
186 <  PartMatch: array[0..8] of Byte = (0, 3, 6, 1, 4, 7, 2, 5, 8);
152 > function TOniImage.WriteToFile(filename: String): Boolean;
153 > begin
154 >  Result := SaveMultiImageToFile(filename, FImages);
155 > end;
156 >
157 >
158 >
159 > procedure TOniImage.DrawOnCanvas(Canvas: TCanvas; Index: Integer);
160   var
161 <  x, y, pixel: Word;
162 <  i: Integer;
161 >  singleimg: TImageData;
162 >  rect: TRect;
163 > begin
164 >  InitImage(singleimg);
165 >  CloneImage(FImages[Index-1], singleimg);
166 >  ConvertImage(singleimg, ifX8R8G8B8);
167 >  rect.Left := 0;
168 >  rect.Top := 0;
169 >  rect.Right := singleimg.Width - 1;
170 >  rect.Bottom := singleimg.Height - 1;
171 >  Canvas.Brush.Color := $C8D0D4;
172 >  Canvas.FillRect(Canvas.ClipRect);
173 >  DisplayImageData(Canvas, rect, singleimg, rect);
174 >  FreeImage(singleimg);
175 > end;
176  
191  PSpc:     TPSpc;
192  txmpimg:  TOniImage;
193  txmpdata: TByteData;
177  
178 <  parts:    array[0..8] of TPart;
179 <  part:     Byte;
180 <  cols:     array[0..2] of Word;
181 <  rows:     array[0..2] of Word;
182 <  col, row: Byte;
178 >
179 >
180 > procedure TOniImage.SaveDataToStream(MipMaps: Boolean; var Target: TStream);
181 > var
182 >  images: TDynImageDataArray;
183 >  mem: TMemoryStream;
184 >  i: Integer;
185   begin
186 < (*
202 <  ConManager.Connection[ConnectionID].LoadDatFilePart(fileid, $08, SizeOf(PSpc), @PSpc);
203 <  PSpc.TXMP := PSpc.TXMP div 256;
204 <  if PSpc.TXMP = 0 then
205 <  begin
206 <    Result := False;
186 >  if Length(FImages) = 0 then
187      Exit;
188 <  end;
209 <  txmpimg := TOniImage.Create;
210 <  txmpimg.LoadFromTXMP(ConnectionID, PSpc.TXMP);
211 <  txmpimg.DecodeImageTo32bit;
212 < //  txmpimg.WriteToBMP('C:\file.bmp');
213 <  txmpimg.GetAs32bit(txmpdata);
214 < {    ShowMessage(IntToStr(txmpimg.Width)+'x'+IntToStr(txmpimg.Height));
215 <    for i:=0 to High(txmpdata) do
216 <      txmpimg.Data[i]:=txmpdata[i];
217 <    txmpimg.WriteToBMP('D:\file2.bmp');
218 < }
219 <  with PSpc do
188 >  if MipMaps then
189    begin
190 <    for i := 0 to 2 do
222 <    begin
223 <      cols[i] := 0;
224 <      rows[i] := 0;
225 <    end;
226 <    for i := 0 to 8 do
190 >    if Length(FImages) = 1 then
191      begin
192 <      part := PartMatch[i];
229 <      col  := i div 3;
230 <      row  := i mod 3;
231 <      if (p2[i].X > 0) or (p2[i].Y > 0) then
232 <      begin
233 <        parts[part].x_txmp := p1[i].X - 1;
234 <        parts[part].y_txmp := p1[i].Y - 1;
235 <        parts[part].x_pspc := 0;
236 <        if col > 0 then
237 <          for x := 0 to col - 1 do
238 <            Inc(parts[part].x_pspc, cols[x]);
239 <        parts[part].y_pspc := 0;
240 <        if row > 0 then
241 <          for y := 0 to row - 1 do
242 <            Inc(parts[part].y_pspc, rows[y]);
243 <        parts[part].w := p2[i].X - p1[i].X + 1;
244 <        parts[part].h := p2[i].Y - p1[i].Y + 1;
245 <        parts[part].used := True;
246 <        cols[col] := parts[part].w;
247 <        rows[row] := parts[part].h;
248 <        SetLength(parts[part].imgdata, parts[part].w * parts[part].h * 4);
249 <        for y := 0 to parts[part].h - 1 do
250 <        begin
251 <          for x := 0 to parts[part].w - 1 do
252 <          begin
253 <            for pixel := 0 to 3 do
254 <            begin
255 <              parts[part].imgdata[(y * parts[part].w + x) * 4 + pixel] :=
256 <                txmpdata[((parts[part].y_txmp + y) * txmpimg.Width +
257 <                parts[part].x_txmp + x) * 4 + pixel];
258 <            end;
259 <          end;
260 <        end;
261 <      end
262 <      else
192 >      if not GenerateMipMaps(FImages[0], 0, images) then
193        begin
194 <        parts[part].used := False;
194 >        ShowMessage('Could not generate MipMaps');
195 >        Exit;
196        end;
197 +    end
198 +    else
199 +    begin
200 +      SetLength(images, Length(FImages));
201 +      for i := 0 to High(FImages) do
202 +        CloneImage(FImages[i], images[i]);
203      end;
204 <
205 <  end;
206 <
207 <  txmpimg.Free;
208 <  txmpimg := TOniImage.Create;
209 <  for i := 0 to 8 do
204 >    mem := TMemoryStream.Create;
205 >    if not SaveMultiImageToStream('dds', mem, images) then
206 >    begin
207 >      ShowMessage('Could not save images to stream');
208 >      Exit;
209 >    end;
210 >    FreeImagesInArray(images);
211 >  end
212 >  else
213    begin
214 <    if parts[i].used then
214 >    mem := TMemoryStream.Create;
215 >    if not SaveImageToStream('dds', mem, FImages[0]) then
216      begin
217 <      SetLength(txmpimg.FData, Length(parts[i].imgdata));
218 <      for pixel := 0 to High(parts[i].imgdata) do
278 <        txmpimg.Data[pixel] := parts[i].imgdata[pixel];
279 <      txmpimg.Width := parts[i].w;
280 <      txmpimg.Height    := parts[i].h;
281 <      txmpimg.StoreType := 8;
282 <      txmpimg.DataType  := [DT_Decoded32];
283 <      txmpimg.Depth     := 32;
284 <      txmpimg.WriteToBMP('M:\' + IntToStr(i) + '.bmp');
217 >      ShowMessage('Could not save image to stream');
218 >      Exit;
219      end;
220    end;
221 <  txmpimg.Free;
221 >  if not Assigned(Target) then
222 >    Target := TMemoryStream.Create;
223 >
224 >  mem.Seek(128, soFromBeginning);
225 >  Target.CopyFrom(mem, mem.Size - 128);
226 >  mem.Free;
227 >  Target.Seek(0, soFromBeginning);
228 > end;
229 >
230 >
231 >
232 >
233  
234 <  Self.FWidth  := 0;
235 <  Self.FHeight := 0;
236 <  for i := 0 to 2 do
237 <  begin
238 <    Inc(Self.FWidth, cols[i]);
239 <    Inc(Self.FHeight, rows[i]);
240 <  end;
241 <  SetLength(Self.FData, Self.FWidth * Self.FHeight * 4);
242 <
243 <  //Combine data parts
244 <
245 <  Self.FDepth     := 32;
246 <  Self.FStoreType := 8;
302 <  Self.FDataType  := [DT_Decoded32];
303 <  //    Self.RevertImage;
304 < *)
234 > function TOniImage.Load(ConnectionID, FileID: Integer): Boolean;
235 > var
236 >  FileInfo: TFileInfo;
237 > begin
238 >  FileInfo := ConManager.Connection[ConnectionID].GetFileInfo(fileid);
239 >  if FileInfo.Extension = 'PSpc' then
240 >    Result := LoadFromPSpc(ConnectionID, fileid)
241 >  else if FileInfo.Extension = 'TXMB' then
242 >    Result := LoadFromTXMB(ConnectionID, fileid)
243 >  else if FileInfo.Extension = 'TXMP' then
244 >    Result := LoadFromTXMP(ConnectionID, fileid)
245 >  else
246 >    Result := False;
247   end;
248  
249  
# Line 319 | Line 261 | var
261    _storetype: Byte;
262    _depth: Byte;
263   begin
264 <  Result := True;
264 >  Result := False;
265    ConManager.Connection[ConnectionID].LoadDatFilePart(fileid, $8C, SizeOf(_width), @_width);
266    ConManager.Connection[ConnectionID].LoadDatFilePart(fileid, $8E, SizeOf(_height), @_height);
267    ConManager.Connection[ConnectionID].LoadDatFilePart(fileid, $90, SizeOf(_storetype), @_storetype);
# Line 433 | Line 375 | begin
375    else
376      ConManager.Connection[ConnectionID].LoadRawFile(fileid, $A0, TStream(data));
377  
436 //  data.Seek(0, soFromBeginning);
437 //  data.SaveToFile('m:\test.txmp');
438
378    data.Seek(0, soFromBeginning);
379 <  result := LoadMultiImageFromStream(data, FImages);
379 >  Result := LoadMultiImageFromStream(data, FImages);
380    data.Free;
381 < {
443 <  if result then
444 <  begin
445 <    for i := 0 to High(FImages) do
446 <    begin
447 <      data := TMemoryStream.Create;
448 <      data.Write(FImages[i].Bits^, FImages[i].Size);
449 <      data.Seek(0, soFromBeginning);
450 <      data.SaveToFile('m:\test.txmp.'+IntToStr(i));
451 <      data.Free;
452 <    end;
453 <  end;
454 < }
381 >
382    if not result then
383    begin
384      ShowMessage('Error while loading file' + #13#10 + DetermineStreamFormat(data));
458 //    data.SaveToFile('m:\prob.dds');
385    end;
386   end;
387  
388  
389  
390  
391 +
392   function TOniImage.LoadFromTXMB(ConnectionID, FileID: Integer): Boolean;
393   var
394 <  i, x, y, x2, y2, pixelid, imgid: Integer;
394 >  i, x, y, imgid: Integer;
395    rows, cols: Word;
396    linkcount: Integer;
397    link: Integer;
# Line 473 | Line 400 | var
400  
401    width, height: Word;
402   begin
403 +  Result := False;
404    ConManager.Connection[ConnectionID].LoadDatFilePart(fileid, $10, SizeOf(width), @width);
405    ConManager.Connection[ConnectionID].LoadDatFilePart(fileid, $12, SizeOf(height), @height);
406    ConManager.Connection[ConnectionID].LoadDatFilePart(fileid, $18, SizeOf(cols), @cols);
# Line 485 | Line 413 | begin
413      link := link div 256;
414      images[i] := TOniImage.Create;
415      images[i].LoadFromTXMP(ConnectionID, link);
488    SetLength(FImages, 1);
489    NewImage(width, height, ifA1R5G5B5, FImages[0]);
416    end;
417 +  SetLength(FImages, 1);
418 +  NewImage(width, height, images[0].Format {ifA1R5G5B5}, FImages[0]);
419    for y := 0 to rows - 1 do
420    begin
421      for x := 0 to cols - 1 do
# Line 497 | Line 425 | begin
425        y_start := 0;
426        for i := 0 to x do
427          if i < x then
428 <          x_start := x_start + images[i].Image[0].Width;
428 >          x_start := x_start + images[i].Image[1].Width;
429        for i := 0 to y do
430          if i < y then
431 <          y_start := y_start + images[i].Image[0].Height;
432 <      CopyRect(images[imgid].Image[0], 0, 0, images[imgid].Image[0].Width,
433 <          images[imgid].Image[0].Height, FImages[0], x_start, y_start);
431 >          y_start := y_start + images[i].Image[1].Height;
432 >      CopyRect(images[imgid].Image[1], 0, 0, images[imgid].Image[1].Width,
433 >          images[imgid].Image[1].Height, FImages[0], x_start, y_start);
434      end;
435    end;
436    for i := 0 to linkcount - 1 do
437      images[i].Free;
438 +  Result := True;
439   end;
440  
441  
442  
443 < procedure TOniImage.SaveDataToStream(MipMaps: Boolean; var Target: TStream);
443 >
444 >
445 > function TOniImage.LoadFromPSpc(ConnectionID, FileID: Integer): Boolean;
446 > type
447 >  TPoint = packed record
448 >    X, Y: Word;
449 >  end;
450 >
451 >  TPSpc = packed record
452 >    p1:   array[0..8] of TPoint;
453 >    p2:   array[0..8] of TPoint;
454 >    TXMP: Integer;
455 >  end;
456 >
457 >  TPart = packed record
458 >    x_txmp, y_txmp: Word;
459 >    x_pspc, y_pspc: Word;
460 >    w, h:    Word;
461 >    imgdata: TImageData;
462 >    used:    Boolean;
463 >  end;
464 > const
465 >  PartMatch: array[0..8] of Byte = (0, 3, 6, 1, 4, 7, 2, 5, 8);
466 >  stretch_x: Integer = 1;
467 >  stretch_y: Integer = 1;
468   var
469 <  images: TDynImageDataArray;
517 <  mem: TMemoryStream;
469 >  x, y: Word;
470    i: Integer;
471 +
472 +  PSpc:     TPSpc;
473 +  txmpimg:  TOniImage;
474 +
475 +  parts:    array[0..8] of TPart;
476 +  part:     Byte;
477 +  cols:     array[0..2] of Word;
478 +  rows:     array[0..2] of Word;
479 +  col, row: Byte;
480 +
481 +  pspcimage: TImageData;
482   begin
483 <  if Length(FImages) = 0 then
483 >  ConManager.Connection[ConnectionID].LoadDatFilePart(fileid, $08, SizeOf(PSpc), @PSpc);
484 >  PSpc.TXMP := PSpc.TXMP div 256;
485 >  if PSpc.TXMP = 0 then
486 >  begin
487 >    Result := False;
488      Exit;
489 <  if MipMaps then
489 >  end;
490 >  txmpimg := TOniImage.Create;
491 >  txmpimg.Load(ConnectionID, PSpc.TXMP);
492 >  CloneImage(txmpimg.Image[1], pspcimage);
493 >  txmpimg.Free;
494 >
495 >  Result := False;
496 >
497 >  with pspc do
498    begin
499 <    if Length(FImages) = 1 then
525 <    begin
526 <      if not GenerateMipMaps(FImages[0], 0, images) then
527 <      begin
528 <        ShowMessage('Could not generate MipMaps');
529 <        Exit;
530 <      end;
531 <    end
532 <    else
499 >    for i := 0 to 2 do
500      begin
501 <      SetLength(images, Length(FImages));
502 <      for i := 0 to High(FImages) do
536 <        CloneImage(FImages[i], images[i]);
501 >      cols[i] := 0;
502 >      rows[i] := 0;
503      end;
504 <    mem := TMemoryStream.Create;
539 <    if not SaveMultiImageToStream('dds', mem, images) then
504 >    for i := 0 to 8 do
505      begin
506 <      ShowMessage('Could not save images to stream');
507 <      Exit;
506 >      part := PartMatch[i];
507 >      col  := i div 3;
508 >      row  := i mod 3;
509 >      if (p2[i].X > 0) or (p2[i].Y > 0) then
510 >      begin
511 >        parts[part].x_txmp := p1[i].X;// - 1;
512 >        parts[part].y_txmp := p1[i].Y;// - 1;
513 >        parts[part].x_pspc := 0;
514 >        if col > 0 then
515 >          for x := 0 to col - 1 do
516 >            Inc(parts[part].x_pspc, cols[x]);
517 >        parts[part].y_pspc := 0;
518 >        if row > 0 then
519 >          for y := 0 to row - 1 do
520 >            Inc(parts[part].y_pspc, rows[y]);
521 >        parts[part].w := Max(p2[i].X - p1[i].X, 1);// + 1;
522 >        parts[part].h := Max(p2[i].Y - p1[i].Y, 1);// + 1;
523 >        parts[part].used := True;
524 >        cols[col] := parts[part].w;
525 >        rows[row] := parts[part].h;
526 >
527 >        NewImage(parts[part].w, parts[part].h, pspcimage.Format, parts[part].imgdata);
528 >
529 >        CopyRect(pspcimage,
530 >            parts[part].x_txmp, parts[part].y_txmp, parts[part].w, parts[part].h,
531 >            parts[part].imgdata, 0, 0);
532 >      end
533 >      else
534 >      begin
535 >        parts[part].used := False;
536 >      end;
537      end;
538 <    FreeImagesInArray(images);
539 <  end
540 <  else
538 >
539 >  end;
540 >
541 >  for i := 0 to 8 do
542    begin
543 <    mem := TMemoryStream.Create;
549 <    if not SaveImageToStream('dds', mem, FImages[0]) then
543 >    if parts[i].used then
544      begin
545 <      ShowMessage('Could not save image to stream');
552 <      Exit;
545 > //      SaveImageToFile('M:\' + IntToStr(i) + '.bmp', parts[i].imgdata);
546      end;
547    end;
555  if not Assigned(Target) then
556    Target := TMemoryStream.Create;
548  
549 < //  mem.Seek(0, soFromBeginning);
550 < //  mem.SaveToFile('m:\dds.dds');
551 <
561 <  mem.Seek(128, soFromBeginning);
562 <  Target.CopyFrom(mem, mem.Size - 128);
563 <  mem.Free;
564 <  Target.Seek(0, soFromBeginning);
565 < end;
549 >  SetLength(FImages, 1);
550 >  x := cols[0] + cols[1] * stretch_x + cols[2];
551 >  y := rows[0] + rows[1] * stretch_y + rows[2];
552  
553 +  NewImage(x, y, pspcimage.Format, FImages[0]);
554  
555 < function TOniImage.LoadFromFile(filename: String): Boolean;
556 < begin
557 <  if not LoadMultiImageFromFile(filename, FImages) then
558 <    ShowMessage('Couldn''t load image file');
559 < end;
560 <
561 <
562 < function TOniImage.WriteToFile(filename: String): Boolean;
563 < begin
564 <  SaveMultiImageToFile(filename, FImages);
565 < end;
566 <
555 >  x := 0;
556 >  for col := 0 to 2 do
557 >  begin
558 >    y := 0;
559 >    for row := 0 to 2 do
560 >    begin
561 >      part := row*3 + col;
562 >      if parts[part].used then
563 >      begin
564 >        if (row = 1) and (col = 1) then
565 >          StretchRect(parts[part].imgdata, 0, 0, parts[part].w, parts[part].h,
566 >              FImages[0], x, y, parts[part].w * stretch_x, parts[part].h * stretch_y, rfNearest)
567 >        else
568 >        if (row = 1) then
569 >          StretchRect(parts[part].imgdata, 0, 0, parts[part].w, parts[part].h,
570 >              FImages[0], x, y, parts[part].w, parts[part].h * stretch_y, rfNearest)
571 >        else
572 >        if (col = 1) then
573 >          StretchRect(parts[part].imgdata, 0, 0, parts[part].w, parts[part].h,
574 >              FImages[0], x, y, parts[part].w * stretch_x, parts[part].h, rfNearest)
575 >        else
576 >          CopyRect(parts[part].imgdata, 0, 0, parts[part].w, parts[part].h,
577 >              FImages[0], x, y );
578 >        if row = 1 then
579 >          y := y + parts[part].h * stretch_y
580 >        else
581 >          y := y + parts[part].h;
582 >      end;
583 >    end;
584 >    if cols[col] > 0 then
585 >    begin
586 >      if (col = 1) then
587 >        x := x + parts[part].w * stretch_x
588 >      else
589 >        x := x + parts[part].w;
590 >    end;
591 >  end;
592  
593 +  FreeImage(pspcimage);
594 +  for i := 0 to 8 do
595 +    if parts[i].used then
596 +      FreeImage(parts[i].imgdata);
597  
598 < function TOniImage.GetImageSize(MipMaps: Boolean): Integer;
583 < var
584 <  i: Integer;
585 < begin
586 <  if Length(FImages) > 0 then
587 <  begin
588 <    Result := FImages[0].Size;
589 <    if mipmaps then
590 <      for i := 1 to High(FImages) do
591 <        Result := Result + FImages[i].Size;
592 <  end
593 <  else
594 <    Result := -1;
598 >  Result := True;
599   end;
600  
601   end.

Diff Legend

Removed lines
+ Added lines
< Changed lines (old)
> Changed lines (new)