Changeset 198 for oup/current/Global
- Timestamp:
- May 26, 2007, 9:28:08 PM (18 years ago)
- Location:
- oup/current/Global
- Files:
-
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
oup/current/Global/Exporters.pas
r192 r198 225 225 img := TOniImage.Create; 226 226 img.Load(ConnectionID, FileID); 227 img.WriteToFile(filename+'.dds'); 227 228 img.WriteToFile(filename+'.bmp'); 228 229 img.Free; -
oup/current/Global/OniImgClass.pas
r194 r198 48 48 implementation 49 49 50 //uses Functions;51 50 uses Img_DDSTypes, ImagingComponents; 52 51 … … 180 179 x_pspc, y_pspc: Word; 181 180 w, h: Word; 182 imgdata: T ByteData;181 imgdata: TImageData; 183 182 used: Boolean; 184 183 end; 185 184 const 186 185 PartMatch: array[0..8] of Byte = (0, 3, 6, 1, 4, 7, 2, 5, 8); 187 var 188 x, y, pixel: Word; 186 stretch_x: Integer = 50; 187 stretch_y: Integer = 1; 188 var 189 x, y: Word; 189 190 i: Integer; 190 191 191 192 PSpc: TPSpc; 192 193 txmpimg: TOniImage; 193 txmpdata: TByteData;194 // txmpdata: TByteData; 194 195 195 196 parts: array[0..8] of TPart; … … 198 199 rows: array[0..2] of Word; 199 200 col, row: Byte; 200 begin 201 (* 201 202 pspcimage: TImageData; 203 begin 202 204 ConManager.Connection[ConnectionID].LoadDatFilePart(fileid, $08, SizeOf(PSpc), @PSpc); 203 205 PSpc.TXMP := PSpc.TXMP div 256; … … 208 210 end; 209 211 txmpimg := TOniImage.Create; 210 txmpimg.LoadFromTXMP(ConnectionID, PSpc.TXMP); 211 txmpimg.DecodeImageTo32bit; 212 // txmpimg.WriteToBMP('C:\file.bmp'); 213 txmpimg.GetAs32bit(txmpdata); 214 { ShowMessage(IntToStr(txmpimg.Width)+'x'+IntToStr(txmpimg.Height)); 215 for i:=0 to High(txmpdata) do 216 txmpimg.Data[i]:=txmpdata[i]; 217 txmpimg.WriteToBMP('D:\file2.bmp'); 218 } 219 with PSpc do 212 txmpimg.Load(ConnectionID, PSpc.TXMP); 213 CloneImage(txmpimg.Image[1], pspcimage); 214 txmpimg.Free; 215 216 with pspc do 220 217 begin 221 218 for i := 0 to 2 do … … 246 243 cols[col] := parts[part].w; 247 244 rows[row] := parts[part].h; 248 SetLength(parts[part].imgdata, parts[part].w * parts[part].h * 4); 249 for y := 0 to parts[part].h - 1 do 250 begin 251 for x := 0 to parts[part].w - 1 do 252 begin 253 for pixel := 0 to 3 do 254 begin 255 parts[part].imgdata[(y * parts[part].w + x) * 4 + pixel] := 256 txmpdata[((parts[part].y_txmp + y) * txmpimg.Width + 257 parts[part].x_txmp + x) * 4 + pixel]; 258 end; 259 end; 260 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); 261 251 end 262 252 else … … 268 258 end; 269 259 270 txmpimg.Free;271 txmpimg := TOniImage.Create;272 260 for i := 0 to 8 do 273 261 begin 274 262 if parts[i].used then 275 263 begin 276 SetLength(txmpimg.FData, Length(parts[i].imgdata)); 277 for pixel := 0 to High(parts[i].imgdata) do 278 txmpimg.Data[pixel] := parts[i].imgdata[pixel]; 279 txmpimg.Width := parts[i].w; 280 txmpimg.Height := parts[i].h; 281 txmpimg.StoreType := 8; 282 txmpimg.DataType := [DT_Decoded32]; 283 txmpimg.Depth := 32; 284 txmpimg.WriteToBMP('M:\' + IntToStr(i) + '.bmp'); 285 end; 286 end; 287 txmpimg.Free; 288 289 Self.FWidth := 0; 290 Self.FHeight := 0; 291 for i := 0 to 2 do 292 begin 293 Inc(Self.FWidth, cols[i]); 294 Inc(Self.FHeight, rows[i]); 295 end; 296 SetLength(Self.FData, Self.FWidth * Self.FHeight * 4); 297 298 //Combine data parts 299 300 Self.FDepth := 32; 301 Self.FStoreType := 8; 302 Self.FDataType := [DT_Decoded32]; 303 // Self.RevertImage; 304 *) 264 // SaveImageToFile('M:\' + IntToStr(i) + '.bmp', parts[i].imgdata); 265 end; 266 end; 267 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 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; 305 306 FreeImage(pspcimage); 307 for i := 0 to 8 do 308 if parts[i].used then 309 FreeImage(parts[i].imgdata); 305 310 end; 306 311 … … 465 470 function TOniImage.LoadFromTXMB(ConnectionID, FileID: Integer): Boolean; 466 471 var 467 i, x, y, x2, y2, pixelid,imgid: Integer;472 i, x, y, imgid: Integer; 468 473 rows, cols: Word; 469 474 linkcount: Integer;
Note:
See TracChangeset
for help on using the changeset viewer.