Changeset 105 for oup/rewrite/Global


Ignore:
Timestamp:
Feb 21, 2007, 1:29:27 AM (18 years ago)
Author:
alloc
Message:
 
Location:
oup/rewrite/Global
Files:
3 edited

Legend:

Unmodified
Added
Removed
  • oup/rewrite/Global/Functions.pas

    r97 r105  
    1111function Decode_Float(buffer: TByteData): Single;
    1212function Encode_Float(input: Single): TByteData;
     13function IntToBin(Value: Byte): String;
    1314function DataToBin(Data: TByteData): String;
    1415function BinToInt(bin: String): Byte;
     
    3940
    4041
    41 
    4242function BoolToStr(bool: Boolean): String;
    4343begin
     
    4949
    5050
    51 
    52 
    5351function HexToLong(hex: String): LongWord;
    5452
     
    7674begin
    7775  if NormalizeHexString(hex) then
    78   begin
    79     Result := StrToInt(hex);
    80 {
    81     hex    := UpperCase(hex);
     76    Result := StrToInt(hex)
     77  else
    8278    Result := 0;
    83     for i := 1 to Length(hex) do
    84     begin
    85       Result := Result shl 4;
    86       case hex[i] of
    87         '0'..'9':
    88           Result := Result + Ord(hex[i]) - 48;
    89         'A'..'F':
    90           Result := Result + Ord(hex[i]) - 55;
    91         else
    92           Result := 0;
    93           Exit;
    94       end;
    95     end;
    96 }
    97   end
    98   else
    99   begin
    100     Result := 0;
    101   end;
    102 end;
    103 
    104 
     79end;
    10580
    10681
     
    10984  Result := buffer[0] + buffer[1] * 256 + buffer[2] * 256 * 256 + buffer[3] * 256 * 256 * 256;
    11085end;
    111 
    112 
    11386
    11487
     
    12699
    127100
    128 
    129 
    130101function Decode_Float(buffer: TByteData): Single;
    131102var
     
    139110
    140111
    141 
    142 
    143112function Encode_Float(input: Single): TByteData;
    144113var
     
    150119
    151120
     121function IntToBin(Value: Byte): String;
     122var
     123  i: Byte;
     124begin
     125  Result := '';
     126  for i := 7 downto 0 do
     127    Result := Result + IntToStr((Value shr i) and $01);
     128end;
    152129
    153130
     
    171148  end;
    172149end;
    173 
    174 
    175150
    176151
     
    193168  end;
    194169end;
    195 
    196170
    197171
  • oup/rewrite/Global/OniImgClass.pas

    r101 r105  
    3939    function GetImageDataSize(fading: Boolean): Integer;
    4040
    41     function GetAsData: TByteData;
    42     function GetAs32bit: TByteData;
     41    procedure GetAsData(var Target: TStream); overload;
     42    procedure GetAsData(var Target: TByteData); overload;
     43    procedure GetAs32bit(var Target: TStream); overload;
     44    procedure GetAs32bit(var Target: TByteData); overload;
     45    procedure GetAsBMP(var Target: TStream); overload;
    4346    procedure GetAsBMP(var Target: TByteData); overload;
    44     procedure GetAsBMP(var Target: TStream); overload;
    4547    function LoadFromBMP(filename: String): Boolean;
    4648    function WriteToBMP(filename: String): Boolean;
    47     function GetMipMappedImage(var faded: TByteData): Boolean;
     49    function GetMipMappedImage(var Target: TStream): Boolean; overload;
     50    function GetMipMappedImage(var Target: TByteData): Boolean; overload;
    4851  published
    4952  end;
     
    369372  txmpimg.DecodeImage;
    370373//  txmpimg.WriteToBMP('C:\file.bmp');
    371   txmpdata := txmpimg.GetAs32bit;
     374  txmpimg.GetAs32bit(txmpdata);
    372375{    ShowMessage(IntToStr(txmpimg.Width)+'x'+IntToStr(txmpimg.Height));
    373376    for i:=0 to High(txmpdata) do
     
    615618
    616619
    617 function TOniImage.GetAsData: TByteData;
     620procedure TOniImage.GetAsData(var Target: TStream);
    618621var
    619622  i:      Integer;
     
    629632  else
    630633    revert := False;
    631   SetLength(Result, Length(Self.FData));
    632   for i := 0 to High(Result) do
    633     Result[i] := Self.FData[i];
     634  if not Assigned(Target) then
     635    Target := TMemoryStream.Create;
     636  Target.Write(FData[0], Length(FData));
     637  Target.Seek(0, soFromBeginning);
    634638  if revert then
    635639    Self.RevertImage;
    636640end;
    637641
    638 
    639 
    640 
    641 function TOniImage.GetAs32bit: TByteData;
    642 var
    643   i: Integer;
     642procedure TOniImage.GetAsData(var Target: TByteData);
     643var
     644  mem: TStream;
     645begin
     646  mem := TMemoryStream.Create;
     647  GetAsData(mem);
     648  SetLength(Target, mem.Size);
     649  mem.Read(Target[0], mem.Size);
     650  mem.Free;
     651end;
     652
     653
     654procedure TOniImage.GetAs32bit(var Target: TStream);
    644655begin
    645656  if not (DT_Decoded32 in Self.FDataType) then
    646657    Self.DecodeImage;
    647   SetLength(Result, Length(Self.FData));
    648   for i := 0 to High(Result) do
    649     Result[i] := Self.FData[i];
    650 end;
    651 
    652 
     658  if not Assigned(Target) then
     659    Target := TMemoryStream.Create;
     660  Target.Write(FData[0], Length(FData));
     661  Target.Seek(0, soFromBeginning);
     662end;
     663
     664procedure TOniImage.GetAs32bit(var Target: TByteData);
     665var
     666  mem: TStream;
     667begin
     668  mem := TMemoryStream.Create;
     669  GetAs32bit(mem);
     670  SetLength(Target, mem.Size);
     671  mem.Read(Target[0], mem.Size);
     672  mem.Free;
     673end;
    653674
    654675
     
    786807
    787808
    788 
    789 function TOniImage.GetMipMappedImage(var faded: TByteData): Boolean;
     809function TOniImage.GetMipMappedImage(var Target: TByteData): Boolean;
    790810var
    791811  i:      Integer;
     
    810830  x := Self.FWidth;
    811831  y := Self.FHeight;
    812   SetLength(faded, x * y * Self.FDepth div 8);
     832  SetLength(Target, x * y * Self.FDepth div 8);
    813833  SetLength(fadelvldata, x * y * Self.FDepth div 8);
    814   for i := 0 to Length(faded) - 1 do
    815   begin
    816     faded[i] := Self.FData[i];
     834  for i := 0 to Length(Target) - 1 do
     835  begin
     836    Target[i] := Self.FData[i];
    817837    fadelvldata[i] := Self.FData[i];
    818838  end;
     
    821841    x := x div 2;
    822842    y := y div 2;
    823     SetLength(faded, Length(faded) + x * y * Self.FDepth div 8);
     843    SetLength(Target, Length(Target) + x * y * Self.FDepth div 8);
    824844    for i := 0 to Length(fadelvldata) - 1 do
    825       faded[Length(faded) - x * y * Self.FDepth div 8 + i] := fadelvldata[i];
     845      Target[Length(Target) - x * y * Self.FDepth div 8 + i] := fadelvldata[i];
    826846  until (x = 1) or (y = 1) or ((x mod 2) = 1) or ((y mod 2) = 1);
    827847  if (x > 1) and (y > 1) then
     
    834854
    835855
     856function TOniImage.GetMipMappedImage(var Target: TStream): Boolean;
     857var
     858  data: TByteData;
     859  streampos: Integer;
     860begin
     861  Result := GetMipMappedImage(data);
     862  if not Assigned(Target) then
     863    Target := TMemoryStream.Create;
     864  streampos := Target.Position;
     865  Target.Write(data[0], Length(data));
     866  Target.Seek(streampos, soFromBeginning);
     867end;
     868
     869
    836870end.
  • oup/rewrite/Global/RawList.pas

    r101 r105  
    1818      FRawListHandlers: TRawListHandlers;
    1919    public
     20      property RawListHandlers: TRawListHandlers read FRawListHandlers;
    2021      procedure InsertRawListHandler(ext: String; needed: Boolean; handler: THandler);
    2122      function GetRawList(ConnectionID, FileID: Integer): TRawDataList;
Note: See TracChangeset for help on using the changeset viewer.