--- oup/current/Global/OniImgClass.pas 2007/05/26 18:26:48 194 +++ oup/current/Global/OniImgClass.pas 2007/05/26 19:28:08 198 @@ -47,7 +47,6 @@ type implementation -//uses Functions; uses Img_DDSTypes, ImagingComponents; @@ -179,26 +178,29 @@ type x_txmp, y_txmp: Word; x_pspc, y_pspc: Word; w, h: Word; - imgdata: TByteData; + imgdata: TImageData; used: Boolean; end; const PartMatch: array[0..8] of Byte = (0, 3, 6, 1, 4, 7, 2, 5, 8); + stretch_x: Integer = 50; + stretch_y: Integer = 1; var - x, y, pixel: Word; + x, y: Word; i: Integer; PSpc: TPSpc; txmpimg: TOniImage; - txmpdata: TByteData; +// txmpdata: TByteData; parts: array[0..8] of TPart; part: Byte; cols: array[0..2] of Word; rows: array[0..2] of Word; col, row: Byte; + + pspcimage: TImageData; begin -(* ConManager.Connection[ConnectionID].LoadDatFilePart(fileid, $08, SizeOf(PSpc), @PSpc); PSpc.TXMP := PSpc.TXMP div 256; if PSpc.TXMP = 0 then @@ -207,16 +209,11 @@ begin Exit; end; txmpimg := TOniImage.Create; - txmpimg.LoadFromTXMP(ConnectionID, PSpc.TXMP); - txmpimg.DecodeImageTo32bit; -// txmpimg.WriteToBMP('C:\file.bmp'); - txmpimg.GetAs32bit(txmpdata); -{ ShowMessage(IntToStr(txmpimg.Width)+'x'+IntToStr(txmpimg.Height)); - for i:=0 to High(txmpdata) do - txmpimg.Data[i]:=txmpdata[i]; - txmpimg.WriteToBMP('D:\file2.bmp'); -} - with PSpc do + txmpimg.Load(ConnectionID, PSpc.TXMP); + CloneImage(txmpimg.Image[1], pspcimage); + txmpimg.Free; + + with pspc do begin for i := 0 to 2 do begin @@ -245,19 +242,12 @@ begin parts[part].used := True; cols[col] := parts[part].w; rows[row] := parts[part].h; - SetLength(parts[part].imgdata, parts[part].w * parts[part].h * 4); - for y := 0 to parts[part].h - 1 do - begin - for x := 0 to parts[part].w - 1 do - begin - for pixel := 0 to 3 do - begin - parts[part].imgdata[(y * parts[part].w + x) * 4 + pixel] := - txmpdata[((parts[part].y_txmp + y) * txmpimg.Width + - parts[part].x_txmp + x) * 4 + pixel]; - end; - end; - end; + + NewImage(parts[part].w, parts[part].h, pspcimage.Format, parts[part].imgdata); + + CopyRect(pspcimage, + parts[part].x_txmp, parts[part].y_txmp, parts[part].w, parts[part].h, + parts[part].imgdata, 0, 0); end else begin @@ -267,41 +257,56 @@ begin end; - txmpimg.Free; - txmpimg := TOniImage.Create; for i := 0 to 8 do begin if parts[i].used then begin - SetLength(txmpimg.FData, Length(parts[i].imgdata)); - for pixel := 0 to High(parts[i].imgdata) do - txmpimg.Data[pixel] := parts[i].imgdata[pixel]; - txmpimg.Width := parts[i].w; - txmpimg.Height := parts[i].h; - txmpimg.StoreType := 8; - txmpimg.DataType := [DT_Decoded32]; - txmpimg.Depth := 32; - txmpimg.WriteToBMP('M:\' + IntToStr(i) + '.bmp'); +// SaveImageToFile('M:\' + IntToStr(i) + '.bmp', parts[i].imgdata); end; end; - txmpimg.Free; - Self.FWidth := 0; - Self.FHeight := 0; - for i := 0 to 2 do + SetLength(FImages, 1); + x := cols[0] + cols[1] * stretch_x + cols[2]; + y := rows[0] + rows[1] * stretch_y + rows[2]; + + NewImage(x, y, pspcimage.Format, FImages[0]); + + x := 0; + for col := 0 to 2 do begin - Inc(Self.FWidth, cols[i]); - Inc(Self.FHeight, rows[i]); + y := 0; + for row := 0 to 2 do + begin + part := row*3 + col; + if (row = 1) and (col = 1) then + StretchRect(parts[part].imgdata, 0, 0, parts[part].w, parts[part].h, + FImages[0], x, y, parts[part].w * stretch_x, parts[part].h * stretch_y, rfNearest) + else + if (row = 1) then + StretchRect(parts[part].imgdata, 0, 0, parts[part].w, parts[part].h, + FImages[0], x, y, parts[part].w, parts[part].h * stretch_y, rfNearest) + else + if (col = 1) then + StretchRect(parts[part].imgdata, 0, 0, parts[part].w, parts[part].h, + FImages[0], x, y, parts[part].w * stretch_x, parts[part].h, rfNearest) + else + CopyRect(parts[part].imgdata, 0, 0, parts[part].w, parts[part].h, + FImages[0], x, y ); + if row = 1 then + y := y + parts[part].h * stretch_y + else + y := y + parts[part].h; + end; + if (part mod 3) = 1 then + x := x + parts[part].w * stretch_x + else + x := x + parts[part].w; end; - SetLength(Self.FData, Self.FWidth * Self.FHeight * 4); - //Combine data parts - - Self.FDepth := 32; - Self.FStoreType := 8; - Self.FDataType := [DT_Decoded32]; - // Self.RevertImage; -*) + FreeImage(pspcimage); + for i := 0 to 8 do + if parts[i].used then + FreeImage(parts[i].imgdata); end; @@ -464,7 +469,7 @@ end; function TOniImage.LoadFromTXMB(ConnectionID, FileID: Integer): Boolean; var - i, x, y, x2, y2, pixelid, imgid: Integer; + i, x, y, imgid: Integer; rows, cols: Word; linkcount: Integer; link: Integer;