47 |
|
|
48 |
|
implementation |
49 |
|
|
50 |
– |
//uses Functions; |
50 |
|
uses Img_DDSTypes, ImagingComponents; |
51 |
|
|
52 |
|
|
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 |
201 |
– |
(* |
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)); |
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 |
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 |
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); |
251 |
|
end |
252 |
|
else |
253 |
|
begin |
257 |
|
|
258 |
|
end; |
259 |
|
|
270 |
– |
txmpimg.Free; |
271 |
– |
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)); |
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'); |
264 |
> |
// SaveImageToFile('M:\' + IntToStr(i) + '.bmp', parts[i].imgdata); |
265 |
|
end; |
266 |
|
end; |
287 |
– |
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; |
296 |
– |
SetLength(Self.FData, Self.FWidth * Self.FHeight * 4); |
305 |
|
|
306 |
< |
//Combine data parts |
307 |
< |
|
308 |
< |
Self.FDepth := 32; |
309 |
< |
Self.FStoreType := 8; |
302 |
< |
Self.FDataType := [DT_Decoded32]; |
303 |
< |
// Self.RevertImage; |
304 |
< |
*) |
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 |
|
|
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; |