Rev 717 | Rev 999 | Go to most recent revision | Show entire file | Regard whitespace | Details | Blame | Last modification | View Log | RSS feed
Rev 717 | Rev 783 | ||
---|---|---|---|
Line 233... | Line 233... | ||
233 | or eax, eax |
233 | or eax, eax |
234 | jz .error |
234 | jz .error |
Line 235... | Line 235... | ||
235 | 235 | ||
Line 236... | Line 236... | ||
236 | push eax |
236 | push eax |
237 | 237 | ||
238 | stdcall img._resize_data, eax, [_width], [_height] |
238 | stdcall img._.resize_data, eax, [_width], [_height] |
Line 239... | Line 239... | ||
239 | or eax, eax |
239 | or eax, eax |
240 | jz .error.2 |
240 | jz .error.2 |
Line 265... | Line 265... | ||
265 | stdcall img._.delete, [_img] |
265 | stdcall img._.delete, [_img] |
266 | ret |
266 | ret |
267 | endp |
267 | endp |
Line 268... | Line 268... | ||
268 | 268 | ||
269 | ;;================================================================================================;; |
269 | ;;================================================================================================;; |
270 | proc img._resize_data _img, _width, _height ;/////////////////////////////////////////////////////;; |
270 | proc img.count _img ;/////////////////////////////////////////////////////////////////////////////;; |
271 | ;;------------------------------------------------------------------------------------------------;; |
271 | ;;------------------------------------------------------------------------------------------------;; |
272 | ;? --- TBD --- ;; |
272 | ;? Get number of images in the list (e.g. in animated GIF file) ;; |
273 | ;;------------------------------------------------------------------------------------------------;; |
273 | ;;------------------------------------------------------------------------------------------------;; |
274 | ;> --- TBD --- ;; |
274 | ;> _img = pointer to image ;; |
275 | ;;------------------------------------------------------------------------------------------------;; |
275 | ;;------------------------------------------------------------------------------------------------;; |
276 | ;< --- TBD --- ;; |
276 | ;< eax = -1 (fail) / >0 (ok) ;; |
277 | ;;================================================================================================;; |
277 | ;;================================================================================================;; |
278 | push ebx |
278 | push ecx edx |
279 | mov ebx, [_img] |
- | |
280 | mov eax, [_height] |
- | |
281 | imul eax, [_width] |
- | |
282 | shl eax, 2 |
279 | mov edx, [_img] |
283 | invoke mem.realloc, [ebx + Image.Data], eax |
280 | stdcall img._.validate, edx |
284 | or eax, eax |
281 | or eax, eax |
Line 285... | Line 282... | ||
285 | jz .error |
282 | jnz .error |
- | 283 | ||
- | 284 | @@: mov eax, [edx + Image.Previous] |
|
286 | 285 | or eax, eax |
|
- | 286 | jz @f |
|
- | 287 | mov edx, eax |
|
- | 288 | jmp @b |
|
- | 289 | ||
287 | mov [ebx + Image.Data], eax |
290 | @@: xor ecx, ecx |
- | 291 | @@: inc ecx |
|
288 | push [_width] |
292 | mov eax, [edx + Image.Next] |
- | 293 | or eax, eax |
|
- | 294 | jz .exit |
|
- | 295 | mov edx, eax |
|
- | 296 | jmp @b |
|
- | 297 | ||
289 | pop [ebx + Image.Width] |
298 | .exit: |
- | 299 | mov eax, ecx |
|
Line 290... | Line 300... | ||
290 | push [_height] |
300 | pop edx ecx |
- | 301 | ret |
|
291 | pop [ebx + Image.Height] |
302 | |
292 | 303 | .error: |
|
293 | .error: |
304 | or eax, -1 |
Line -... | Line 305... | ||
- | 305 | pop edx ecx |
|
- | 306 | ret |
|
294 | pop ebx |
307 | endp |
295 | ret |
308 | |
296 | endp |
309 | ;;//// image processing //////////////////////////////////////////////////////////////////////////;; |
297 | 310 | ||
298 | ;;================================================================================================;; |
311 | ;;================================================================================================;; |
Line 319... | Line 332... | ||
319 | ;;================================================================================================;; |
332 | ;;================================================================================================;; |
320 | xor eax, eax |
333 | xor eax, eax |
321 | ret |
334 | ret |
322 | endp |
335 | endp |
Line 323... | Line -... | ||
323 | - | ||
324 | ;;//// image processing //////////////////////////////////////////////////////////////////////////;; |
- | |
325 | 336 | ||
326 | ;;================================================================================================;; |
337 | ;;================================================================================================;; |
327 | proc img.flip _img, _flip_kind ;//////////////////////////////////////////////////////////////////;; |
338 | proc img.flip _img, _flip_kind ;//////////////////////////////////////////////////////////////////;; |
328 | ;;------------------------------------------------------------------------------------------------;; |
339 | ;;------------------------------------------------------------------------------------------------;; |
329 | ;? --- TBD --- ;; |
340 | ;? Flip image ;; |
330 | ;;------------------------------------------------------------------------------------------------;; |
341 | ;;------------------------------------------------------------------------------------------------;; |
- | 342 | ;> _img = pointer to image ;; |
|
331 | ;> --- TBD --- ;; |
343 | ;> _flip_kind = one of FLIP_* constants ;; |
332 | ;;------------------------------------------------------------------------------------------------;; |
344 | ;;------------------------------------------------------------------------------------------------;; |
333 | ;< eax = false / true ;; |
345 | ;< eax = false / true ;; |
334 | ;;================================================================================================;; |
346 | ;;================================================================================================;; |
335 | locals |
347 | locals |
Line 345... | Line 357... | ||
345 | mov ecx, [esi + Image.Height] |
357 | mov ecx, [esi + Image.Height] |
346 | mov eax, [esi + Image.Width] |
358 | mov eax, [esi + Image.Width] |
347 | shl eax, 2 |
359 | shl eax, 2 |
348 | mov [scanline_len], eax |
360 | mov [scanline_len], eax |
Line -... | Line 361... | ||
- | 361 | ||
- | 362 | push esi |
|
349 | 363 | ||
350 | test [_flip_kind], FLIP_VERTICAL |
364 | test [_flip_kind], FLIP_VERTICAL |
Line 351... | Line 365... | ||
351 | jz .dont_flip_vert |
365 | jz .dont_flip_vert |
352 | 366 | ||
Line 358... | Line 372... | ||
358 | 372 | ||
359 | .next_line_vert: |
373 | .next_line_vert: |
Line 360... | Line 374... | ||
360 | push ecx |
374 | push ecx |
- | 375 | ||
361 | 376 | mov ecx, [scanline_len] |
|
362 | mov ecx, [scanline_len] |
377 | shr ecx, 2 |
363 | @@: lodsd |
378 | @@: lodsd |
364 | xchg eax, [edi] |
379 | xchg eax, [edi] |
365 | mov [esi - 4], eax |
380 | mov [esi - 4], eax |
366 | add edi, 4 |
381 | add edi, 4 |
Line -... | Line 382... | ||
- | 382 | dec ecx |
|
367 | add ecx, -4 |
383 | jnz @b |
368 | jnz @b |
384 | |
369 | 385 | pop ecx |
|
370 | mov eax, [scanline_len] |
- | |
371 | shl eax, 1 |
- | |
372 | sub edi, eax |
386 | mov eax, [scanline_len] |
373 | 387 | shl eax, 1 |
|
Line 374... | Line 388... | ||
374 | pop ecx |
388 | sub edi, eax |
Line -... | Line 389... | ||
- | 389 | dec ecx |
|
- | 390 | jnz .next_line_vert |
|
375 | dec ecx |
391 | |
376 | jnz .next_line_vert |
392 | .dont_flip_vert: |
Line -... | Line 393... | ||
- | 393 | ||
- | 394 | pop esi |
|
- | 395 | ||
- | 396 | test [_flip_kind], FLIP_HORIZONTAL |
|
- | 397 | jz .exit |
|
- | 398 | ||
377 | 399 | mov ecx, [esi + Image.Height] |
|
- | 400 | mov esi, [esi + Image.Data] |
|
- | 401 | lea edi, [esi - 4] |
|
- | 402 | add edi, [scanline_len] |
|
- | 403 | ||
- | 404 | .next_line_horz: |
|
- | 405 | push ecx esi edi |
|
- | 406 | ||
- | 407 | mov ecx, [scanline_len] |
|
- | 408 | shr ecx, 3 |
|
- | 409 | @@: mov eax, [esi] |
|
- | 410 | xchg eax, [edi] |
|
- | 411 | mov [esi], eax |
|
- | 412 | add esi, 4 |
|
- | 413 | add edi, -4 |
|
- | 414 | dec ecx |
|
- | 415 | jnz @b |
|
Line 378... | Line 416... | ||
378 | .dont_flip_vert: |
416 | |
379 | 417 | pop edi esi ecx |
|
380 | test [_flip_kind], FLIP_HORIZONTAL |
418 | add esi, [scanline_len] |
381 | jz .exit |
419 | add edi, [scanline_len] |
Line 392... | Line 430... | ||
392 | xor eax, eax |
430 | xor eax, eax |
393 | pop edi esi |
431 | pop edi esi |
394 | ret |
432 | ret |
395 | endp |
433 | endp |
Line -... | Line 434... | ||
- | 434 | ||
- | 435 | ;;================================================================================================;; |
|
- | 436 | proc img.rotate _img, _rotate_kind ;//////////////////////////////////////////////////////////////;; |
|
- | 437 | ;;------------------------------------------------------------------------------------------------;; |
|
- | 438 | ;? Rotate image ;; |
|
- | 439 | ;;------------------------------------------------------------------------------------------------;; |
|
- | 440 | ;> _img = pointer to image ;; |
|
- | 441 | ;> _rotate_kind = one of ROTATE_* constants ;; |
|
- | 442 | ;;------------------------------------------------------------------------------------------------;; |
|
- | 443 | ;< eax = false / true ;; |
|
- | 444 | ;;================================================================================================;; |
|
- | 445 | locals |
|
- | 446 | scanline_len_old dd ? |
|
- | 447 | scanline_len_new dd ? |
|
- | 448 | scanline_pixels_new dd ? |
|
- | 449 | line_buffer dd ? |
|
- | 450 | pixels_ptr dd ? |
|
- | 451 | endl |
|
- | 452 | ||
- | 453 | mov [line_buffer], 0 |
|
- | 454 | ||
- | 455 | push ebx esi edi |
|
- | 456 | stdcall img._.validate, [_img] |
|
- | 457 | or eax, eax |
|
- | 458 | jnz .error |
|
- | 459 | ||
- | 460 | cmp [_rotate_kind], ROTATE_90_CCW |
|
- | 461 | je .rotate_ccw_low |
|
- | 462 | cmp [_rotate_kind], ROTATE_90_CW |
|
- | 463 | je .rotate_cw_low |
|
- | 464 | cmp [_rotate_kind], ROTATE_180 |
|
- | 465 | je .flip |
|
- | 466 | jmp .exit |
|
- | 467 | ||
- | 468 | .rotate_ccw_low: |
|
- | 469 | mov ebx, [_img] |
|
- | 470 | mov eax, [ebx + Image.Height] |
|
- | 471 | mov [scanline_pixels_new], eax |
|
- | 472 | shl eax, 2 |
|
- | 473 | mov [scanline_len_new], eax |
|
- | 474 | ||
- | 475 | invoke mem.alloc, eax |
|
- | 476 | or eax, eax |
|
- | 477 | jz .error |
|
- | 478 | mov [line_buffer], eax |
|
- | 479 | ||
- | 480 | mov ecx, [ebx + Image.Width] |
|
- | 481 | lea eax, [ecx * 4] |
|
- | 482 | mov [scanline_len_old], eax |
|
- | 483 | ||
- | 484 | mov eax, [scanline_len_new] |
|
- | 485 | imul eax, ecx |
|
- | 486 | add eax, [ebx + Image.Data] |
|
- | 487 | mov [pixels_ptr], eax |
|
- | 488 | ||
- | 489 | .next_column_ccw_low: |
|
- | 490 | dec ecx |
|
- | 491 | jz .exchange_dims |
|
- | 492 | push ecx |
|
- | 493 | ||
- | 494 | mov edx, [scanline_len_old] |
|
- | 495 | add [scanline_len_old], -4 |
|
- | 496 | ||
- | 497 | mov ecx, [scanline_pixels_new] |
|
- | 498 | mov esi, [ebx + Image.Data] |
|
- | 499 | mov edi, [line_buffer] |
|
- | 500 | @@: mov eax, [esi] |
|
- | 501 | stosd |
|
- | 502 | add esi, edx |
|
- | 503 | dec ecx |
|
- | 504 | jnz @b |
|
- | 505 | ||
- | 506 | mov eax, [scanline_pixels_new] |
|
- | 507 | mov edi, [ebx + Image.Data] |
|
- | 508 | lea esi, [edi + 4] |
|
- | 509 | mov edx, [scanline_len_old] |
|
- | 510 | shr edx, 2 |
|
- | 511 | @@: mov ecx, edx |
|
- | 512 | rep movsd |
|
- | 513 | add esi, 4 |
|
- | 514 | dec eax |
|
- | 515 | jnz @b |
|
- | 516 | ||
- | 517 | mov eax, [scanline_len_new] |
|
- | 518 | sub [pixels_ptr], eax |
|
- | 519 | mov ecx, [scanline_pixels_new] |
|
- | 520 | mov esi, [line_buffer] |
|
- | 521 | mov edi, [pixels_ptr] |
|
- | 522 | rep movsd |
|
- | 523 | ||
- | 524 | pop ecx |
|
- | 525 | jmp .next_column_ccw_low |
|
- | 526 | ||
- | 527 | .rotate_cw_low: |
|
- | 528 | mov ebx, [_img] |
|
- | 529 | mov eax, [ebx + Image.Height] |
|
- | 530 | mov [scanline_pixels_new], eax |
|
- | 531 | shl eax, 2 |
|
- | 532 | mov [scanline_len_new], eax |
|
- | 533 | ||
- | 534 | invoke mem.alloc, eax |
|
- | 535 | or eax, eax |
|
- | 536 | jz .error |
|
- | 537 | mov [line_buffer], eax |
|
- | 538 | ||
- | 539 | mov ecx, [ebx + Image.Width] |
|
- | 540 | lea eax, [ecx * 4] |
|
- | 541 | mov [scanline_len_old], eax |
|
- | 542 | ||
- | 543 | mov eax, [scanline_len_new] |
|
- | 544 | imul eax, ecx |
|
- | 545 | add eax, [ebx + Image.Data] |
|
- | 546 | mov [pixels_ptr], eax |
|
- | 547 | ||
- | 548 | .next_column_cw_low: |
|
- | 549 | dec ecx |
|
- | 550 | js .exchange_dims |
|
- | 551 | push ecx |
|
- | 552 | ||
- | 553 | mov edx, [scanline_len_old] |
|
- | 554 | add [scanline_len_old], -4 |
|
- | 555 | ||
- | 556 | mov ecx, [scanline_pixels_new] |
|
- | 557 | mov esi, [pixels_ptr] |
|
- | 558 | add esi, -4 |
|
- | 559 | mov edi, [line_buffer] |
|
- | 560 | @@: mov eax, [esi] |
|
- | 561 | stosd |
|
- | 562 | sub esi, edx |
|
- | 563 | dec ecx |
|
- | 564 | jnz @b |
|
- | 565 | ||
- | 566 | mov eax, [scanline_pixels_new] |
|
- | 567 | dec eax |
|
- | 568 | mov edi, [ebx + Image.Data] |
|
- | 569 | add edi, [scanline_len_old] |
|
- | 570 | lea esi, [edi + 4] |
|
- | 571 | mov edx, [scanline_len_old] |
|
- | 572 | shr edx, 2 |
|
- | 573 | @@: mov ecx, edx |
|
- | 574 | rep movsd |
|
- | 575 | add esi, 4 |
|
- | 576 | dec eax |
|
- | 577 | jnz @b |
|
- | 578 | ||
- | 579 | mov eax, [scanline_len_new] |
|
- | 580 | sub [pixels_ptr], eax |
|
- | 581 | mov ecx, [scanline_pixels_new] |
|
- | 582 | mov esi, [line_buffer] |
|
- | 583 | mov edi, [pixels_ptr] |
|
- | 584 | rep movsd |
|
- | 585 | ||
- | 586 | pop ecx |
|
- | 587 | jmp .next_column_cw_low |
|
- | 588 | ||
- | 589 | .flip: |
|
- | 590 | jmp .exit |
|
- | 591 | ||
- | 592 | .exchange_dims: |
|
- | 593 | push [ebx + Image.Width] [ebx + Image.Height] |
|
- | 594 | pop [ebx + Image.Width] [ebx + Image.Height] |
|
- | 595 | ||
- | 596 | .exit: |
|
- | 597 | invoke mem.free, [line_buffer] |
|
- | 598 | xor eax, eax |
|
- | 599 | inc eax |
|
- | 600 | pop edi esi ebx |
|
- | 601 | ret |
|
- | 602 | ||
- | 603 | .error: |
|
- | 604 | invoke mem.free, [line_buffer] |
|
- | 605 | xor eax, eax |
|
- | 606 | pop edi esi ebx |
|
- | 607 | ret |
|
- | 608 | endp |
|
Line 396... | Line 609... | ||
396 | 609 | ||
397 | 610 | ||
398 | ;;================================================================================================;; |
611 | ;;================================================================================================;; |
399 | ;;////////////////////////////////////////////////////////////////////////////////////////////////;; |
612 | ;;////////////////////////////////////////////////////////////////////////////////////////////////;; |
Line 450... | Line 663... | ||
450 | @@: invoke mem.free, edx |
663 | @@: invoke mem.free, edx |
451 | pop edx |
664 | pop edx |
452 | ret |
665 | ret |
453 | endp |
666 | endp |
Line -... | Line 667... | ||
- | 667 | ||
- | 668 | ;;================================================================================================;; |
|
- | 669 | proc img._.resize_data _img, _width, _height ;////////////////////////////////////////////////////;; |
|
- | 670 | ;;------------------------------------------------------------------------------------------------;; |
|
- | 671 | ;? --- TBD --- ;; |
|
- | 672 | ;;------------------------------------------------------------------------------------------------;; |
|
- | 673 | ;> --- TBD --- ;; |
|
- | 674 | ;;------------------------------------------------------------------------------------------------;; |
|
- | 675 | ;< --- TBD --- ;; |
|
- | 676 | ;;================================================================================================;; |
|
- | 677 | push ebx |
|
- | 678 | mov ebx, [_img] |
|
- | 679 | mov eax, [_height] |
|
- | 680 | imul eax, [_width] |
|
- | 681 | shl eax, 2 |
|
- | 682 | invoke mem.realloc, [ebx + Image.Data], eax |
|
- | 683 | or eax, eax |
|
- | 684 | jz .error |
|
- | 685 | ||
- | 686 | mov [ebx + Image.Data], eax |
|
- | 687 | push [_width] |
|
- | 688 | pop [ebx + Image.Width] |
|
- | 689 | push [_height] |
|
- | 690 | pop [ebx + Image.Height] |
|
- | 691 | ||
- | 692 | .error: |
|
- | 693 | pop ebx |
|
- | 694 | ret |
|
- | 695 | endp |
|
Line 454... | Line 696... | ||
454 | 696 | ||
455 | 697 | ||
456 | ;;================================================================================================;; |
698 | ;;================================================================================================;; |
457 | ;;////////////////////////////////////////////////////////////////////////////////////////////////;; |
699 | ;;////////////////////////////////////////////////////////////////////////////////////////////////;; |
Line 495... | Line 737... | ||
495 | img.to_rgb , 'img.to_rgb' , \ |
737 | img.to_rgb , 'img.to_rgb' , \ |
496 | img.decode , 'img.decode' , \ |
738 | img.decode , 'img.decode' , \ |
497 | img.encode , 'img.encode' , \ |
739 | img.encode , 'img.encode' , \ |
498 | img.create , 'img.create' , \ |
740 | img.create , 'img.create' , \ |
499 | img.destroy , 'img.destroy' , \ |
741 | img.destroy , 'img.destroy' , \ |
- | 742 | img.count , 'img.count' , \ |
|
500 | img.lock_bits , 'img.lock_bits' , \ |
743 | img.lock_bits , 'img.lock_bits' , \ |
501 | img.unlock_bits , 'img.unlock_bits'>>>>>>>>>>>>>>>>>>> |
744 | img.unlock_bits , 'img.unlock_bits' , \ |
- | 745 | img.flip , 'img.flip' , \ |
|
- | 746 | img.rotate , 'img.rotate'>>>>>>>>>>>>>>>>>>>>> |