--- oup/current/Global/RawList.pas 2007/03/23 03:07:58 124 +++ oup/current/Global/RawList.pas 2007/04/01 15:40:16 146 @@ -29,7 +29,7 @@ var implementation uses - Template, ConnectionManager, Access_OniArchive, Classes, SysUtils; + Template, ConnectionManager, Access_OniArchive, Classes, SysUtils, Math; function AGDB(ConnectionID, FileID: Integer): TRawDataList; @@ -312,8 +312,21 @@ var storetype: Byte; datasize: Integer; mipmap: Byte; - bpp: Byte; - minside: Byte; + + function GetImgSize(w,h, storetype: Integer): Integer; + begin + case storetype of + 0, 1, 2: + Result := w*h*2; + 8: + Result := w*h*4; + 9: + Result := Max(1, w div 4) * Max(1, h div 4) * 8; + else + Result := -1; + end; + end; + begin ConManager.Connection[ConnectionID].LoadDatFilePart(fileid, $88, SizeOf(mipmap), @mipmap); ConManager.Connection[ConnectionID].LoadDatFilePart(fileid, $8C, SizeOf(x), @x); @@ -323,27 +336,14 @@ begin ConManager.Connection[ConnectionID].LoadDatFilePart(fileid, $A0, 4, @link_mac); - minside := 1; - case storetype of - 0, 1, 2: - bpp := 16; - 8: - bpp := 32; - 9: - begin - bpp := 4; - minside := 4; - end; - end; - - datasize := (x * y * bpp) div 8; + datasize := GetImgSize(x, y, storetype); if (mipmap and $01) > 0 then begin repeat - x := x div 2; - y := y div 2; - datasize := datasize + (x * y * bpp) div 8; - until (x = minside) or (y = minside); + x := Max(x div 2, 1); + y := Max(y div 2, 1); + datasize := datasize + GetImgSize(x, y, storetype); + until (x = 1) and (y = 1); end; SetLength(Result, 1); @@ -424,7 +424,7 @@ end; initialization RawLists := TRawLists.Create; - RawLists.InsertRawListHandler('AGDB',False,AGDB); + RawLists.InsertRawListHandler('AGDB', False, AGDB); RawLists.InsertRawListHandler('AKVA', True, AKVA); RawLists.InsertRawListHandler('BINA', True, BINA); RawLists.InsertRawListHandler('OSBD', True, OSBD);