Changeset 105 for oup/rewrite/Global
- Timestamp:
- Feb 21, 2007, 1:29:27 AM (18 years ago)
- Location:
- oup/rewrite/Global
- Files:
-
- 3 edited
Legend:
- Unmodified
- Added
- Removed
-
oup/rewrite/Global/Functions.pas
r97 r105 11 11 function Decode_Float(buffer: TByteData): Single; 12 12 function Encode_Float(input: Single): TByteData; 13 function IntToBin(Value: Byte): String; 13 14 function DataToBin(Data: TByteData): String; 14 15 function BinToInt(bin: String): Byte; … … 39 40 40 41 41 42 42 function BoolToStr(bool: Boolean): String; 43 43 begin … … 49 49 50 50 51 52 53 51 function HexToLong(hex: String): LongWord; 54 52 … … 76 74 begin 77 75 if NormalizeHexString(hex) then 78 begin 79 Result := StrToInt(hex); 80 { 81 hex := UpperCase(hex); 76 Result := StrToInt(hex) 77 else 82 78 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 79 end; 105 80 106 81 … … 109 84 Result := buffer[0] + buffer[1] * 256 + buffer[2] * 256 * 256 + buffer[3] * 256 * 256 * 256; 110 85 end; 111 112 113 86 114 87 … … 126 99 127 100 128 129 130 101 function Decode_Float(buffer: TByteData): Single; 131 102 var … … 139 110 140 111 141 142 143 112 function Encode_Float(input: Single): TByteData; 144 113 var … … 150 119 151 120 121 function IntToBin(Value: Byte): String; 122 var 123 i: Byte; 124 begin 125 Result := ''; 126 for i := 7 downto 0 do 127 Result := Result + IntToStr((Value shr i) and $01); 128 end; 152 129 153 130 … … 171 148 end; 172 149 end; 173 174 175 150 176 151 … … 193 168 end; 194 169 end; 195 196 170 197 171 -
oup/rewrite/Global/OniImgClass.pas
r101 r105 39 39 function GetImageDataSize(fading: Boolean): Integer; 40 40 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; 43 46 procedure GetAsBMP(var Target: TByteData); overload; 44 procedure GetAsBMP(var Target: TStream); overload;45 47 function LoadFromBMP(filename: String): Boolean; 46 48 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; 48 51 published 49 52 end; … … 369 372 txmpimg.DecodeImage; 370 373 // txmpimg.WriteToBMP('C:\file.bmp'); 371 txmp data := txmpimg.GetAs32bit;374 txmpimg.GetAs32bit(txmpdata); 372 375 { ShowMessage(IntToStr(txmpimg.Width)+'x'+IntToStr(txmpimg.Height)); 373 376 for i:=0 to High(txmpdata) do … … 615 618 616 619 617 function TOniImage.GetAsData: TByteData;620 procedure TOniImage.GetAsData(var Target: TStream); 618 621 var 619 622 i: Integer; … … 629 632 else 630 633 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); 634 638 if revert then 635 639 Self.RevertImage; 636 640 end; 637 641 638 639 640 641 function TOniImage.GetAs32bit: TByteData; 642 var 643 i: Integer; 642 procedure TOniImage.GetAsData(var Target: TByteData); 643 var 644 mem: TStream; 645 begin 646 mem := TMemoryStream.Create; 647 GetAsData(mem); 648 SetLength(Target, mem.Size); 649 mem.Read(Target[0], mem.Size); 650 mem.Free; 651 end; 652 653 654 procedure TOniImage.GetAs32bit(var Target: TStream); 644 655 begin 645 656 if not (DT_Decoded32 in Self.FDataType) then 646 657 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); 662 end; 663 664 procedure TOniImage.GetAs32bit(var Target: TByteData); 665 var 666 mem: TStream; 667 begin 668 mem := TMemoryStream.Create; 669 GetAs32bit(mem); 670 SetLength(Target, mem.Size); 671 mem.Read(Target[0], mem.Size); 672 mem.Free; 673 end; 653 674 654 675 … … 786 807 787 808 788 789 function TOniImage.GetMipMappedImage(var faded: TByteData): Boolean; 809 function TOniImage.GetMipMappedImage(var Target: TByteData): Boolean; 790 810 var 791 811 i: Integer; … … 810 830 x := Self.FWidth; 811 831 y := Self.FHeight; 812 SetLength( faded, x * y * Self.FDepth div 8);832 SetLength(Target, x * y * Self.FDepth div 8); 813 833 SetLength(fadelvldata, x * y * Self.FDepth div 8); 814 for i := 0 to Length( faded) - 1 do815 begin 816 faded[i] := Self.FData[i];834 for i := 0 to Length(Target) - 1 do 835 begin 836 Target[i] := Self.FData[i]; 817 837 fadelvldata[i] := Self.FData[i]; 818 838 end; … … 821 841 x := x div 2; 822 842 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); 824 844 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]; 826 846 until (x = 1) or (y = 1) or ((x mod 2) = 1) or ((y mod 2) = 1); 827 847 if (x > 1) and (y > 1) then … … 834 854 835 855 856 function TOniImage.GetMipMappedImage(var Target: TStream): Boolean; 857 var 858 data: TByteData; 859 streampos: Integer; 860 begin 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); 867 end; 868 869 836 870 end. -
oup/rewrite/Global/RawList.pas
r101 r105 18 18 FRawListHandlers: TRawListHandlers; 19 19 public 20 property RawListHandlers: TRawListHandlers read FRawListHandlers; 20 21 procedure InsertRawListHandler(ext: String; needed: Boolean; handler: THandler); 21 22 function GetRawList(ConnectionID, FileID: Integer): TRawDataList;
Note:
See TracChangeset
for help on using the changeset viewer.