| 15 |
|
function GetHeight(MipGen: Integer): Integer; |
| 16 |
|
function GetImageFormat: TImageFormat; |
| 17 |
|
procedure SetImageFormat(Format: TImageFormat); |
| 18 |
+ |
function pGetImageFormatInfo: TImageFormatInfo; |
| 19 |
|
function GetHasMipMaps: Boolean; |
| 20 |
|
protected |
| 21 |
|
public |
| 24 |
|
property Width[MipGen: Integer]: Integer read GetWidth; |
| 25 |
|
property Height[MipGen: Integer]: Integer read GetHeight; |
| 26 |
|
property Format: TImageFormat read GetImageFormat write SetImageFormat; |
| 27 |
+ |
property FormatInfo: TImageFormatInfo read pGetImageFormatInfo; |
| 28 |
|
property HasMipMaps: Boolean read GetHasMipMaps; |
| 29 |
|
|
| 30 |
|
constructor Create; |
| 47 |
|
|
| 48 |
|
implementation |
| 49 |
|
|
| 48 |
– |
//uses Functions; |
| 50 |
|
uses Img_DDSTypes, ImagingComponents; |
| 51 |
|
|
| 52 |
|
|
| 56 |
|
rect: TRect; |
| 57 |
|
begin |
| 58 |
|
InitImage(singleimg); |
| 59 |
< |
CloneImage(FImages[Index], singleimg); |
| 59 |
> |
CloneImage(FImages[Index-1], singleimg); |
| 60 |
|
ConvertImage(singleimg, ifX8R8G8B8); |
| 61 |
|
rect.Left := 0; |
| 62 |
|
rect.Top := 0; |
| 131 |
|
end; |
| 132 |
|
|
| 133 |
|
|
| 134 |
+ |
function TOniImage.pGetImageFormatInfo: TImageFormatInfo; |
| 135 |
+ |
begin |
| 136 |
+ |
if Length(FImages) > 0 then |
| 137 |
+ |
GetImageFormatInfo(FImages[0].Format, Result); |
| 138 |
+ |
end; |
| 139 |
+ |
|
| 140 |
+ |
|
| 141 |
|
function TOniImage.GetHasMipMaps: Boolean; |
| 142 |
|
begin |
| 143 |
|
Result := Length(FImages) > 1; |
| 178 |
|
x_txmp, y_txmp: Word; |
| 179 |
|
x_pspc, y_pspc: Word; |
| 180 |
|
w, h: Word; |
| 181 |
< |
imgdata: TByteData; |
| 181 |
> |
imgdata: TImageData; |
| 182 |
|
used: Boolean; |
| 183 |
|
end; |
| 184 |
|
const |
| 185 |
|
PartMatch: array[0..8] of Byte = (0, 3, 6, 1, 4, 7, 2, 5, 8); |
| 186 |
+ |
stretch_x: Integer = 50; |
| 187 |
+ |
stretch_y: Integer = 1; |
| 188 |
|
var |
| 189 |
< |
x, y, pixel: Word; |
| 189 |
> |
x, y: Word; |
| 190 |
|
i: Integer; |
| 191 |
|
|
| 192 |
|
PSpc: TPSpc; |
| 193 |
|
txmpimg: TOniImage; |
| 194 |
< |
txmpdata: TByteData; |
| 194 |
> |
// txmpdata: TByteData; |
| 195 |
|
|
| 196 |
|
parts: array[0..8] of TPart; |
| 197 |
|
part: Byte; |
| 198 |
|
cols: array[0..2] of Word; |
| 199 |
|
rows: array[0..2] of Word; |
| 200 |
|
col, row: Byte; |
| 201 |
+ |
|
| 202 |
+ |
pspcimage: TImageData; |
| 203 |
|
begin |
| 192 |
– |
(* |
| 204 |
|
ConManager.Connection[ConnectionID].LoadDatFilePart(fileid, $08, SizeOf(PSpc), @PSpc); |
| 205 |
|
PSpc.TXMP := PSpc.TXMP div 256; |
| 206 |
|
if PSpc.TXMP = 0 then |
| 209 |
|
Exit; |
| 210 |
|
end; |
| 211 |
|
txmpimg := TOniImage.Create; |
| 212 |
< |
txmpimg.LoadFromTXMP(ConnectionID, PSpc.TXMP); |
| 213 |
< |
txmpimg.DecodeImageTo32bit; |
| 214 |
< |
// txmpimg.WriteToBMP('C:\file.bmp'); |
| 215 |
< |
txmpimg.GetAs32bit(txmpdata); |
| 216 |
< |
{ ShowMessage(IntToStr(txmpimg.Width)+'x'+IntToStr(txmpimg.Height)); |
| 206 |
< |
for i:=0 to High(txmpdata) do |
| 207 |
< |
txmpimg.Data[i]:=txmpdata[i]; |
| 208 |
< |
txmpimg.WriteToBMP('D:\file2.bmp'); |
| 209 |
< |
} |
| 210 |
< |
with PSpc do |
| 212 |
> |
txmpimg.Load(ConnectionID, PSpc.TXMP); |
| 213 |
> |
CloneImage(txmpimg.Image[1], pspcimage); |
| 214 |
> |
txmpimg.Free; |
| 215 |
> |
|
| 216 |
> |
with pspc do |
| 217 |
|
begin |
| 218 |
|
for i := 0 to 2 do |
| 219 |
|
begin |
| 242 |
|
parts[part].used := True; |
| 243 |
|
cols[col] := parts[part].w; |
| 244 |
|
rows[row] := parts[part].h; |
| 245 |
< |
SetLength(parts[part].imgdata, parts[part].w * parts[part].h * 4); |
| 246 |
< |
for y := 0 to parts[part].h - 1 do |
| 247 |
< |
begin |
| 248 |
< |
for x := 0 to parts[part].w - 1 do |
| 249 |
< |
begin |
| 250 |
< |
for pixel := 0 to 3 do |
| 245 |
< |
begin |
| 246 |
< |
parts[part].imgdata[(y * parts[part].w + x) * 4 + pixel] := |
| 247 |
< |
txmpdata[((parts[part].y_txmp + y) * txmpimg.Width + |
| 248 |
< |
parts[part].x_txmp + x) * 4 + pixel]; |
| 249 |
< |
end; |
| 250 |
< |
end; |
| 251 |
< |
end; |
| 245 |
> |
|
| 246 |
> |
NewImage(parts[part].w, parts[part].h, pspcimage.Format, parts[part].imgdata); |
| 247 |
> |
|
| 248 |
> |
CopyRect(pspcimage, |
| 249 |
> |
parts[part].x_txmp, parts[part].y_txmp, parts[part].w, parts[part].h, |
| 250 |
> |
parts[part].imgdata, 0, 0); |
| 251 |
|
end |
| 252 |
|
else |
| 253 |
|
begin |
| 257 |
|
|
| 258 |
|
end; |
| 259 |
|
|
| 261 |
– |
txmpimg.Free; |
| 262 |
– |
txmpimg := TOniImage.Create; |
| 260 |
|
for i := 0 to 8 do |
| 261 |
|
begin |
| 262 |
|
if parts[i].used then |
| 263 |
|
begin |
| 264 |
< |
SetLength(txmpimg.FData, Length(parts[i].imgdata)); |
| 268 |
< |
for pixel := 0 to High(parts[i].imgdata) do |
| 269 |
< |
txmpimg.Data[pixel] := parts[i].imgdata[pixel]; |
| 270 |
< |
txmpimg.Width := parts[i].w; |
| 271 |
< |
txmpimg.Height := parts[i].h; |
| 272 |
< |
txmpimg.StoreType := 8; |
| 273 |
< |
txmpimg.DataType := [DT_Decoded32]; |
| 274 |
< |
txmpimg.Depth := 32; |
| 275 |
< |
txmpimg.WriteToBMP('M:\' + IntToStr(i) + '.bmp'); |
| 264 |
> |
// SaveImageToFile('M:\' + IntToStr(i) + '.bmp', parts[i].imgdata); |
| 265 |
|
end; |
| 266 |
|
end; |
| 278 |
– |
txmpimg.Free; |
| 267 |
|
|
| 268 |
< |
Self.FWidth := 0; |
| 269 |
< |
Self.FHeight := 0; |
| 270 |
< |
for i := 0 to 2 do |
| 268 |
> |
SetLength(FImages, 1); |
| 269 |
> |
x := cols[0] + cols[1] * stretch_x + cols[2]; |
| 270 |
> |
y := rows[0] + rows[1] * stretch_y + rows[2]; |
| 271 |
> |
|
| 272 |
> |
NewImage(x, y, pspcimage.Format, FImages[0]); |
| 273 |
> |
|
| 274 |
> |
x := 0; |
| 275 |
> |
for col := 0 to 2 do |
| 276 |
|
begin |
| 277 |
< |
Inc(Self.FWidth, cols[i]); |
| 278 |
< |
Inc(Self.FHeight, rows[i]); |
| 277 |
> |
y := 0; |
| 278 |
> |
for row := 0 to 2 do |
| 279 |
> |
begin |
| 280 |
> |
part := row*3 + col; |
| 281 |
> |
if (row = 1) and (col = 1) then |
| 282 |
> |
StretchRect(parts[part].imgdata, 0, 0, parts[part].w, parts[part].h, |
| 283 |
> |
FImages[0], x, y, parts[part].w * stretch_x, parts[part].h * stretch_y, rfNearest) |
| 284 |
> |
else |
| 285 |
> |
if (row = 1) then |
| 286 |
> |
StretchRect(parts[part].imgdata, 0, 0, parts[part].w, parts[part].h, |
| 287 |
> |
FImages[0], x, y, parts[part].w, parts[part].h * stretch_y, rfNearest) |
| 288 |
> |
else |
| 289 |
> |
if (col = 1) then |
| 290 |
> |
StretchRect(parts[part].imgdata, 0, 0, parts[part].w, parts[part].h, |
| 291 |
> |
FImages[0], x, y, parts[part].w * stretch_x, parts[part].h, rfNearest) |
| 292 |
> |
else |
| 293 |
> |
CopyRect(parts[part].imgdata, 0, 0, parts[part].w, parts[part].h, |
| 294 |
> |
FImages[0], x, y ); |
| 295 |
> |
if row = 1 then |
| 296 |
> |
y := y + parts[part].h * stretch_y |
| 297 |
> |
else |
| 298 |
> |
y := y + parts[part].h; |
| 299 |
> |
end; |
| 300 |
> |
if (part mod 3) = 1 then |
| 301 |
> |
x := x + parts[part].w * stretch_x |
| 302 |
> |
else |
| 303 |
> |
x := x + parts[part].w; |
| 304 |
|
end; |
| 287 |
– |
SetLength(Self.FData, Self.FWidth * Self.FHeight * 4); |
| 288 |
– |
|
| 289 |
– |
//Combine data parts |
| 305 |
|
|
| 306 |
< |
Self.FDepth := 32; |
| 307 |
< |
Self.FStoreType := 8; |
| 308 |
< |
Self.FDataType := [DT_Decoded32]; |
| 309 |
< |
// Self.RevertImage; |
| 295 |
< |
*) |
| 306 |
> |
FreeImage(pspcimage); |
| 307 |
> |
for i := 0 to 8 do |
| 308 |
> |
if parts[i].used then |
| 309 |
> |
FreeImage(parts[i].imgdata); |
| 310 |
|
end; |
| 311 |
|
|
| 312 |
|
|
| 437 |
|
ConManager.Connection[ConnectionID].LoadRawFile(fileid, $9C, TStream(data)) |
| 438 |
|
else |
| 439 |
|
ConManager.Connection[ConnectionID].LoadRawFile(fileid, $A0, TStream(data)); |
| 440 |
+ |
|
| 441 |
+ |
// data.Seek(0, soFromBeginning); |
| 442 |
+ |
// data.SaveToFile('m:\test.txmp'); |
| 443 |
+ |
|
| 444 |
|
data.Seek(0, soFromBeginning); |
| 445 |
|
result := LoadMultiImageFromStream(data, FImages); |
| 446 |
|
data.Free; |
| 447 |
< |
|
| 447 |
> |
{ |
| 448 |
> |
if result then |
| 449 |
> |
begin |
| 450 |
> |
for i := 0 to High(FImages) do |
| 451 |
> |
begin |
| 452 |
> |
data := TMemoryStream.Create; |
| 453 |
> |
data.Write(FImages[i].Bits^, FImages[i].Size); |
| 454 |
> |
data.Seek(0, soFromBeginning); |
| 455 |
> |
data.SaveToFile('m:\test.txmp.'+IntToStr(i)); |
| 456 |
> |
data.Free; |
| 457 |
> |
end; |
| 458 |
> |
end; |
| 459 |
> |
} |
| 460 |
|
if not result then |
| 461 |
|
begin |
| 462 |
|
ShowMessage('Error while loading file' + #13#10 + DetermineStreamFormat(data)); |
| 469 |
|
|
| 470 |
|
function TOniImage.LoadFromTXMB(ConnectionID, FileID: Integer): Boolean; |
| 471 |
|
var |
| 472 |
< |
i, x, y, x2, y2, pixelid, imgid: Integer; |
| 472 |
> |
i, x, y, imgid: Integer; |
| 473 |
|
rows, cols: Word; |
| 474 |
|
linkcount: Integer; |
| 475 |
|
link: Integer; |