Changeset 181 for oup/current/Global
- Timestamp:
- May 19, 2007, 7:54:34 PM (18 years ago)
- Location:
- oup/current/Global
- Files:
-
- 1 added
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
oup/current/Global/OniImgClass.pas
r128 r181 3 3 interface 4 4 5 uses Math, Dialogs, Types, SysUtils, Classes, Data, ConnectionManager, TypeDefs; 5 uses Math, Dialogs, Types, SysUtils, Classes, Data, ConnectionManager, TypeDefs, 6 Imaging, ImagingTypes; 6 7 7 8 type 8 9 TImgDataType = set of (DT_OniReverted, DT_Oni, DT_Decoded32); 10 9 11 10 12 type … … 18 20 FStoreType: Byte; 19 21 22 FImage: TImageData; 23 20 24 function ResizeImage(oldx, oldy: Integer; img: TByteData): TByteData; 21 25 procedure RevertImage; … … 23 27 protected 24 28 public 29 property Image: TImageData Read FImage Write FImage; 25 30 property Loaded: Boolean Read FLoaded Write FLoaded; 26 31 property DataType: TImgDataType Read FDataType Write FDataType; … … 36 41 function LoadFromTXMP(ConnectionID, FileID: Integer): Boolean; 37 42 function LoadFromTXMB(ConnectionID, FileID: Integer): Boolean; 43 function GetImgSize(w,h, storetype: Integer): Integer; 38 44 function GetImageDataSize(fading: Boolean): Integer; 39 45 … … 57 63 58 64 //uses Functions; 59 60 65 uses Img_DDSTypes; 61 66 62 67 … … 70 75 Self.FDepth := 0; 71 76 Self.FStoreType := 0; 77 78 InitImage(FImage); 72 79 end; 73 80 … … 473 480 var 474 481 img_addr: Integer; 482 data: TMemoryStream; 483 hdr: TDDSDXTHeader; 484 imginfo: Integer; 485 x,y, i: Integer; 475 486 begin 476 487 Result := True; 477 488 ConManager.Connection[ConnectionID].LoadDatFilePart(fileid, $8C, SizeOf(Self.FWidth), @Self.FWidth); 478 489 ConManager.Connection[ConnectionID].LoadDatFilePart(fileid, $8E, SizeOf(Self.FHeight), @Self.FHeight); 479 ConManager.Connection[ConnectionID].LoadDatFilePart(fileid, $90, SizeOf(Self.FStoreType), 480 @Self.FStoreType);490 ConManager.Connection[ConnectionID].LoadDatFilePart(fileid, $90, SizeOf(Self.FStoreType), @Self.FStoreType); 491 ConManager.Connection[ConnectionID].LoadDatFilePart(fileid, $88, SizeOf(imginfo), @imginfo); 481 492 if ConManager.Connection[ConnectionID].DataOS = DOS_WIN then 482 493 ConManager.Connection[ConnectionID].LoadDatFilePart(fileid, $9C, SizeOf(img_addr), @img_addr) … … 486 497 case Self.FStoreType of 487 498 0, 1, 2: 488 begin489 SetLength(Self.FData, Self.FWidth * Self.FHeight * 2);490 499 Self.FDepth := 16; 491 end;492 500 8: 493 begin494 SetLength(Self.FData, Self.FWidth * Self.FHeight * 4);495 501 Self.FDepth := 32; 496 end;497 502 9: 498 begin499 SetLength(Self.FData, Self.FWidth * Self.FHeight div 2);500 503 Self.FDepth := 16; 501 end;502 504 else 503 505 Result := False; … … 505 507 end; 506 508 509 if ConManager.Connection[ConnectionID].DataOS = DOS_WIN then 510 ConManager.Connection[ConnectionID].LoadRawFile(fileid, $9C, TStream(data)) 511 else 512 ConManager.Connection[ConnectionID].LoadRawFile(fileid, $A0, TStream(data)); 513 514 with hdr do 515 begin 516 FOURCC := 'DDS '; 517 with SURFACEDESC2 do 518 begin 519 Size := 124; 520 Flags := DDSD_CAPS or DDSD_PIXELFORMAT or DDSD_WIDTH or DDSD_HEIGHT; 521 if FStoreType = 9 then 522 Flags := Flags or DDSD_LINEARSIZE 523 else 524 Flags := Flags or DDSD_PITCH; 525 if (imginfo and $01) > 0 then 526 Flags := Flags or DDSD_MIPMAPCOUNT; 527 Height := FHeight; 528 Width := FWidth; 529 if FStoreType = 9 then 530 PitchOrLinearSize := FWidth * FHeight div 2 531 else 532 PitchOrLinearSize := FWidth * FDepth div 2; 533 Depth := 0; 534 MipMapCount := 1; 535 x := FWidth; 536 y := FHeight; 537 while (x > 1) and (y > 1) do 538 begin 539 x := x div 2; 540 y := y div 2; 541 Inc(MipMapCount); 542 end; 543 for i := 1 to 11 do 544 Reserved[i] := 0; 545 with PIXELFORMAT do 546 begin 547 Size := 32; 548 if FStoreType = 9 then 549 Flags := DDPF_FOURCC 550 else 551 Flags := DDPF_RGB; 552 end; 553 end; 554 end; 555 LoadImageFromStream(data, FImage); 556 { 507 557 if ConManager.Connection[ConnectionID].DataOS = DOS_WIN then 508 558 ConManager.Connection[ConnectionID].LoadRawFile(fileid, $9C, FData) 509 559 else 510 560 ConManager.Connection[ConnectionID].LoadRawFile(fileid, $A0, FData); 511 561 } 512 562 Self.FDataType := [DT_OniReverted, DT_Oni]; 513 563 end; … … 584 634 585 635 636 function TOniImage.GetImgSize(w,h, storetype: Integer): Integer; 637 begin 638 case storetype of 639 0, 1, 2: 640 Result := w*h*2; 641 8: 642 Result := w*h*4; 643 9: 644 Result := Max(1, w div 4) * Max(1, h div 4) * 8; 645 else 646 Result := -1; 647 end; 648 end; 649 586 650 587 651 function TOniImage.GetImageDataSize(fading: Boolean): Integer; … … 589 653 size: Integer; 590 654 x, y: Word; 591 592 function GetImgSize(w,h, storetype: Integer): Integer;593 begin594 case storetype of595 0, 1, 2:596 Result := w*h*2;597 8:598 Result := w*h*4;599 9:600 Result := Max(1, w div 4) * Max(1, h div 4) * 8;601 else602 Result := -1;603 end;604 end;605 606 655 begin 607 656 x := Self.FWidth;
Note:
See TracChangeset
for help on using the changeset viewer.