| 19 |
|
|
| 20 |
|
function ResizeImage(oldx, oldy: Integer; img: TByteData): TByteData; |
| 21 |
|
procedure RevertImage; |
| 22 |
– |
procedure DecodeImage; |
| 22 |
|
procedure DecompressImage; |
| 23 |
|
protected |
| 24 |
|
public |
| 37 |
|
function LoadFromTXMB(ConnectionID, FileID: Integer): Boolean; |
| 38 |
|
function GetImageDataSize(fading: Boolean): Integer; |
| 39 |
|
|
| 40 |
+ |
procedure DecodeImageTo32bit; |
| 41 |
+ |
|
| 42 |
|
procedure GetAsData(var Target: TStream); overload; |
| 43 |
|
procedure GetAsData(var Target: TByteData); overload; |
| 44 |
|
procedure GetAs32bit(var Target: TStream); overload; |
| 132 |
|
|
| 133 |
|
|
| 134 |
|
|
| 135 |
< |
procedure TOniImage.DecodeImage; |
| 135 |
> |
procedure TOniImage.DecodeImageTo32bit; |
| 136 |
|
var |
| 137 |
|
x, y: Integer; |
| 138 |
|
tempd: TByteData; |
| 371 |
|
end; |
| 372 |
|
txmpimg := TOniImage.Create; |
| 373 |
|
txmpimg.LoadFromTXMP(ConnectionID, PSpc.TXMP); |
| 374 |
< |
txmpimg.DecodeImage; |
| 374 |
> |
txmpimg.DecodeImageTo32bit; |
| 375 |
|
// txmpimg.WriteToBMP('C:\file.bmp'); |
| 376 |
|
txmpimg.GetAs32bit(txmpdata); |
| 377 |
|
{ ShowMessage(IntToStr(txmpimg.Width)+'x'+IntToStr(txmpimg.Height)); |
| 536 |
|
link := link div 256; |
| 537 |
|
images_decoded[i] := TOniImage.Create; |
| 538 |
|
images_decoded[i].LoadFromTXMP(ConnectionID, link); |
| 539 |
< |
images_decoded[i].DecodeImage; |
| 539 |
> |
images_decoded[i].DecodeImageTo32bit; |
| 540 |
|
images_decoded[i].RevertImage; |
| 541 |
|
end; |
| 542 |
|
SetLength(Self.FData, Self.FWidth * Self.FHeight * 4); |
| 588 |
|
var |
| 589 |
|
size: Integer; |
| 590 |
|
x, y: Word; |
| 591 |
< |
bpp: Byte; |
| 592 |
< |
begin |
| 593 |
< |
case Self.FStoreType of |
| 594 |
< |
9: |
| 595 |
< |
bpp := 8; |
| 596 |
< |
0, 1, 2: |
| 597 |
< |
bpp := 16; |
| 598 |
< |
8: |
| 599 |
< |
bpp := 32; |
| 591 |
> |
|
| 592 |
> |
function GetImgSize(w,h, storetype: Integer): Integer; |
| 593 |
> |
begin |
| 594 |
> |
case storetype of |
| 595 |
> |
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 |
|
else |
| 602 |
< |
Result := 0; |
| 603 |
< |
Exit; |
| 602 |
> |
Result := -1; |
| 603 |
> |
end; |
| 604 |
|
end; |
| 605 |
|
|
| 606 |
+ |
begin |
| 607 |
|
x := Self.FWidth; |
| 608 |
|
y := Self.FHeight; |
| 609 |
< |
size := x * y * bpp div 8; |
| 609 |
> |
size := GetImgSize(x, y, FStoreType); |
| 610 |
|
if fading then |
| 611 |
|
begin |
| 612 |
|
repeat |
| 613 |
< |
x := x div 2; |
| 614 |
< |
y := y div 2; |
| 615 |
< |
size := size + x * y * bpp div 8; |
| 616 |
< |
until (x = 1) or (y = 1); |
| 613 |
> |
x := Max(x div 2, 1); |
| 614 |
> |
y := Max(y div 2, 1); |
| 615 |
> |
size := size + GetImgSize(x, y, FStoreType); |
| 616 |
> |
until (x = 1) and (y = 1); |
| 617 |
|
end; |
| 618 |
|
Result := size; |
| 619 |
|
end; |
| 657 |
|
procedure TOniImage.GetAs32bit(var Target: TStream); |
| 658 |
|
begin |
| 659 |
|
if not (DT_Decoded32 in Self.FDataType) then |
| 660 |
< |
Self.DecodeImage; |
| 660 |
> |
Self.DecodeImageTo32bit; |
| 661 |
|
if not Assigned(Target) then |
| 662 |
|
Target := TMemoryStream.Create; |
| 663 |
|
Target.Write(FData[0], Length(FData)); |
| 686 |
|
i, x, y: Integer; |
| 687 |
|
begin |
| 688 |
|
if not (DT_Decoded32 in Self.FDataType) then |
| 689 |
< |
Self.DecodeImage; |
| 689 |
> |
Self.DecodeImageTo32bit; |
| 690 |
|
|
| 691 |
|
SetLength(Target, Self.FWidth * Self.FHeight * 3 + 54); |
| 692 |
|
for y := 0 to Self.FHeight - 1 do |