Stefan Schuermans commited on 2011-10-16 11:30:55
Showing 3 changed files, with 125 additions and 3 deletions.
... | ... |
@@ -295,9 +295,7 @@ void BlinkenFrameSetColor(stBlinkenFrame * pFrame, int y, int x, |
295 | 295 |
char)(((((color & 0xFF) * pFrame->maxval + 127) / 255) * alpha + |
296 | 296 |
(unsigned long)pFrame->ppData[y][i + 2] * alpha_) / 255); |
297 | 297 |
for (c = 3; c < pFrame->channels; c++) |
298 |
- pFrame->ppData[y][i + c] = (unsigned char)((0 |
|
299 |
- + |
|
300 |
- (unsigned long) |
|
298 |
+ pFrame->ppData[y][i + c] = (unsigned char)((0 + (unsigned long) |
|
301 | 299 |
pFrame->ppData[y][i + |
302 | 300 |
c] * |
303 | 301 |
alpha_) / 255); |
... | ... |
@@ -510,6 +508,10 @@ void BlinkenFrameScale(stBlinkenFrame * pFrame, int height, int width) |
510 | 508 |
ox1 = (double)(nx + 1) / scaleHor - 0.000001; |
511 | 509 |
if (oy < 0 || ox < 0 || oy1 >= pFrame->height || ox1 >= pFrame->width) // out |
512 | 510 |
// |
511 |
+ // |
|
512 |
+ // |
|
513 |
+ // |
|
514 |
+ // |
|
513 | 515 |
// of |
514 | 516 |
// old |
515 | 517 |
// picture |
... | ... |
@@ -696,11 +698,19 @@ int BlinkenFrameToNetwork(stBlinkenFrame * pFrame, etBlinkenProto proto, |
696 | 698 |
case BlinkenProtoBlp: |
697 | 699 |
if (maxLength < (int)sizeof(stBlinkenProtoBlpHdr) + pFrame->height * pFrame->width) // buffer |
698 | 700 |
// |
701 |
+ // |
|
702 |
+ // |
|
703 |
+ // |
|
704 |
+ // |
|
699 | 705 |
// too |
700 | 706 |
// short |
701 | 707 |
return -1; |
702 | 708 |
((stBlinkenProtoBlpHdr *) pData)->magic = htonl(BlinkenProtoBlpMagic); // build |
703 | 709 |
// |
710 |
+ // |
|
711 |
+ // |
|
712 |
+ // |
|
713 |
+ // |
|
704 | 714 |
// header |
705 | 715 |
((stBlinkenProtoBlpHdr *) pData)->frameNo = htonl(0); |
706 | 716 |
((stBlinkenProtoBlpHdr *) pData)->width = htons((uint16_t) pFrame->width); |
... | ... |
@@ -721,11 +731,19 @@ int BlinkenFrameToNetwork(stBlinkenFrame * pFrame, etBlinkenProto proto, |
721 | 731 |
case BlinkenProtoEblp: |
722 | 732 |
if (maxLength < (int)sizeof(stBlinkenProtoEblpHdr) + pFrame->height * pFrame->width) // buffer |
723 | 733 |
// |
734 |
+ // |
|
735 |
+ // |
|
736 |
+ // |
|
737 |
+ // |
|
724 | 738 |
// too |
725 | 739 |
// short |
726 | 740 |
return -1; |
727 | 741 |
((stBlinkenProtoEblpHdr *) pData)->magic = htonl(BlinkenProtoEblpMagic); // build |
728 | 742 |
// |
743 |
+ // |
|
744 |
+ // |
|
745 |
+ // |
|
746 |
+ // |
|
729 | 747 |
// header |
730 | 748 |
((stBlinkenProtoEblpHdr *) pData)->frameNo = htonl(0); |
731 | 749 |
((stBlinkenProtoEblpHdr *) pData)->width = |
... | ... |
@@ -749,11 +767,19 @@ int BlinkenFrameToNetwork(stBlinkenFrame * pFrame, etBlinkenProto proto, |
749 | 767 |
case BlinkenProtoMcuf: |
750 | 768 |
if (maxLength < (int)sizeof(stBlinkenProtoMcufHdr) + pFrame->height * pFrame->width * pFrame->channels) // buffer |
751 | 769 |
// |
770 |
+ // |
|
771 |
+ // |
|
772 |
+ // |
|
773 |
+ // |
|
752 | 774 |
// too |
753 | 775 |
// short |
754 | 776 |
return -1; |
755 | 777 |
((stBlinkenProtoMcufHdr *) pData)->magic = htonl(BlinkenProtoMcufMagic); // build |
756 | 778 |
// |
779 |
+ // |
|
780 |
+ // |
|
781 |
+ // |
|
782 |
+ // |
|
757 | 783 |
// header |
758 | 784 |
((stBlinkenProtoMcufHdr *) pData)->height = |
759 | 785 |
htons((uint16_t) pFrame->height); |
... | ... |
@@ -790,16 +816,28 @@ stBlinkenFrame *BlinkenFrameFromNetwork(char *pData, int length, |
790 | 816 |
*pProto = BlinkenProtoBlp; |
791 | 817 |
height = ntohs(((stBlinkenProtoBlpHdr *) pData)->height); // get header |
792 | 818 |
// |
819 |
+ // |
|
820 |
+ // |
|
821 |
+ // |
|
822 |
+ // |
|
793 | 823 |
// data |
794 | 824 |
width = ntohs(((stBlinkenProtoBlpHdr *) pData)->width); |
795 | 825 |
if (length < (int)sizeof(stBlinkenProtoBlpHdr) + height * width) // check |
796 | 826 |
// |
827 |
+ // |
|
828 |
+ // |
|
829 |
+ // |
|
830 |
+ // |
|
797 | 831 |
// length |
798 | 832 |
// of |
799 | 833 |
// packet |
800 | 834 |
return NULL; |
801 | 835 |
if (height < BlinkenHeightMin || height > BlinkenHeightMax || // check |
802 | 836 |
// |
837 |
+ // |
|
838 |
+ // |
|
839 |
+ // |
|
840 |
+ // |
|
803 | 841 |
// header |
804 | 842 |
// data |
805 | 843 |
width < BlinkenWidthMin || width > BlinkenWidthMax) |
... | ... |
@@ -823,16 +861,28 @@ stBlinkenFrame *BlinkenFrameFromNetwork(char *pData, int length, |
823 | 861 |
*pProto = BlinkenProtoEblp; |
824 | 862 |
height = ntohs(((stBlinkenProtoEblpHdr *) pData)->height); // get header |
825 | 863 |
// |
864 |
+ // |
|
865 |
+ // |
|
866 |
+ // |
|
867 |
+ // |
|
826 | 868 |
// data |
827 | 869 |
width = ntohs(((stBlinkenProtoEblpHdr *) pData)->width); |
828 | 870 |
if (length < (int)sizeof(stBlinkenProtoEblpHdr) + width * height) // check |
829 | 871 |
// |
872 |
+ // |
|
873 |
+ // |
|
874 |
+ // |
|
875 |
+ // |
|
830 | 876 |
// length |
831 | 877 |
// of |
832 | 878 |
// packet |
833 | 879 |
return NULL; |
834 | 880 |
if (height < BlinkenHeightMin || height > BlinkenHeightMax || // check |
835 | 881 |
// |
882 |
+ // |
|
883 |
+ // |
|
884 |
+ // |
|
885 |
+ // |
|
836 | 886 |
// header |
837 | 887 |
// data |
838 | 888 |
width < BlinkenWidthMin || width > BlinkenWidthMax) |
... | ... |
@@ -856,18 +906,30 @@ stBlinkenFrame *BlinkenFrameFromNetwork(char *pData, int length, |
856 | 906 |
*pProto = BlinkenProtoMcuf; |
857 | 907 |
height = ntohs(((stBlinkenProtoMcufHdr *) pData)->height); // get header |
858 | 908 |
// |
909 |
+ // |
|
910 |
+ // |
|
911 |
+ // |
|
912 |
+ // |
|
859 | 913 |
// data |
860 | 914 |
width = ntohs(((stBlinkenProtoMcufHdr *) pData)->width); |
861 | 915 |
channels = ntohs(((stBlinkenProtoMcufHdr *) pData)->channels); |
862 | 916 |
maxval = ntohs(((stBlinkenProtoMcufHdr *) pData)->maxval); |
863 | 917 |
if (length < (int)sizeof(stBlinkenProtoMcufHdr) + height * width * channels) // check |
864 | 918 |
// |
919 |
+ // |
|
920 |
+ // |
|
921 |
+ // |
|
922 |
+ // |
|
865 | 923 |
// length |
866 | 924 |
// of |
867 | 925 |
// packet |
868 | 926 |
return NULL; |
869 | 927 |
if (height < BlinkenHeightMin || height > BlinkenHeightMax || // check |
870 | 928 |
// |
929 |
+ // |
|
930 |
+ // |
|
931 |
+ // |
|
932 |
+ // |
|
871 | 933 |
// header |
872 | 934 |
// data |
873 | 935 |
width < BlinkenWidthMin || width > BlinkenWidthMax || |
... | ... |
@@ -876,6 +938,10 @@ stBlinkenFrame *BlinkenFrameFromNetwork(char *pData, int length, |
876 | 938 |
return NULL; |
877 | 939 |
pFrame = BlinkenFrameNew(height, width, channels, maxval, 0); // create |
878 | 940 |
// |
941 |
+ // |
|
942 |
+ // |
|
943 |
+ // |
|
944 |
+ // |
|
879 | 945 |
// frame |
880 | 946 |
// according |
881 | 947 |
// to |
... | ... |
@@ -307,9 +307,17 @@ stBlinkenMovie *BlinkenMngLoad(char *pFilename) |
307 | 307 |
|
308 | 308 |
// if movie has more than one frame and the last frame is empty |
309 | 309 |
// |
310 |
+ // |
|
311 |
+ // |
|
312 |
+ // |
|
313 |
+ // |
|
310 | 314 |
// with duration of 1ms, remove last frame |
311 | 315 |
// - a black frame with 1ms duration is inserted by MNG library |
312 | 316 |
// |
317 |
+ // |
|
318 |
+ // |
|
319 |
+ // |
|
320 |
+ // |
|
313 | 321 |
// when MNG requests to clean canvas after displaying |
314 | 322 |
// - the reqauest to clear canvas after end of MNG anmation is |
315 | 323 |
// needed to preserve duration of last frame (when converting |
... | ... |
@@ -410,6 +418,10 @@ int BlinkenMngSave(stBlinkenMovie * pMovie, char *pFilename) |
410 | 418 |
if (mng_putchunk_mhdr(hMNG, data->width, data->height, // dimensions |
411 | 419 |
1000, 0, frame_cnt, total_duration, // ticks |
412 | 420 |
// |
421 |
+ // |
|
422 |
+ // |
|
423 |
+ // |
|
424 |
+ // |
|
413 | 425 |
// per |
414 | 426 |
// second, |
415 | 427 |
// layer, |
... | ... |
@@ -431,6 +443,10 @@ int BlinkenMngSave(stBlinkenMovie * pMovie, char *pFilename) |
431 | 443 |
// end of the MNG as side effect |
432 | 444 |
if (mng_putchunk_term(hMNG, MNG_TERMACTION_CLEAR, MNG_ITERACTION_CLEAR, // show |
433 | 445 |
// |
446 |
+ // |
|
447 |
+ // |
|
448 |
+ // |
|
449 |
+ // |
|
434 | 450 |
// last |
435 | 451 |
// frame |
436 | 452 |
// forever |
... | ... |
@@ -459,14 +475,26 @@ int BlinkenMngSave(stBlinkenMovie * pMovie, char *pFilename) |
459 | 475 |
|
460 | 476 |
if (mng_putchunk_fram(hMNG, MNG_FALSE, frame_no == 0 ? MNG_FRAMINGMODE_1 : MNG_FRAMINGMODE_NOCHANGE, // empty, |
461 | 477 |
// |
478 |
+ // |
|
479 |
+ // |
|
480 |
+ // |
|
481 |
+ // |
|
462 | 482 |
// mode |
463 | 483 |
0, MNG_NULL, // frame name |
464 | 484 |
MNG_CHANGEDELAY_DEFAULT, MNG_CHANGETIMOUT_NO, MNG_CHANGECLIPPING_NO, MNG_CHANGESYNCID_NO, // changing |
465 | 485 |
// |
486 |
+ // |
|
487 |
+ // |
|
488 |
+ // |
|
489 |
+ // |
|
466 | 490 |
// only |
467 | 491 |
// delay |
468 | 492 |
frame_duration, 0, // new delay, |
469 | 493 |
// |
494 |
+ // |
|
495 |
+ // |
|
496 |
+ // |
|
497 |
+ // |
|
470 | 498 |
// no new |
471 | 499 |
// timeout |
472 | 500 |
0, 0, 0, 0, 0, // no new boundary |
... | ... |
@@ -476,6 +504,10 @@ int BlinkenMngSave(stBlinkenMovie * pMovie, char *pFilename) |
476 | 504 |
|
477 | 505 |
if (mng_putchunk_defi(hMNG, 0, MNG_DONOTSHOW_VISIBLE, MNG_ABSTRACT, // no |
478 | 506 |
// |
507 |
+ // |
|
508 |
+ // |
|
509 |
+ // |
|
510 |
+ // |
|
479 | 511 |
// ID, |
480 | 512 |
// visible, |
481 | 513 |
// abstract |
... | ... |
@@ -487,12 +519,20 @@ int BlinkenMngSave(stBlinkenMovie * pMovie, char *pFilename) |
487 | 519 |
|
488 | 520 |
if (mng_putchunk_ihdr(hMNG, data->width, data->height, 8, MNG_COLORTYPE_RGB, // dimensions |
489 | 521 |
// |
522 |
+ // |
|
523 |
+ // |
|
524 |
+ // |
|
525 |
+ // |
|
490 | 526 |
// and |
491 | 527 |
// 8 |
492 | 528 |
// bit |
493 | 529 |
// RGB |
494 | 530 |
MNG_COMPRESSION_DEFLATE, MNG_FILTER_ADAPTIVE, MNG_INTERLACE_NONE // deflate |
495 | 531 |
// |
532 |
+ // |
|
533 |
+ // |
|
534 |
+ // |
|
535 |
+ // |
|
496 | 536 |
// compression, |
497 | 537 |
// adaptive |
498 | 538 |
// filter, |
... | ... |
@@ -730,6 +730,10 @@ stBlinkenMovie *BlinkenMovieLoadBlm(char *pFilename) |
730 | 730 |
for (x = 0;; x++) { |
731 | 731 |
BlinkenFrameSetPixel(pFrame, y, x, 0, (unsigned char)(pixel[0] == '1' ? 1 : 0)); // set |
732 | 732 |
// |
733 |
+ // |
|
734 |
+ // |
|
735 |
+ // |
|
736 |
+ // |
|
733 | 737 |
// pixel |
734 | 738 |
if (fscanf(pFile, "%1[01]", pixel) != 1) // read next pixel |
735 | 739 |
break; |
... | ... |
@@ -809,6 +813,10 @@ stBlinkenMovie *BlinkenMovieLoadBmm(char *pFilename) |
809 | 813 |
break; |
810 | 814 |
BlinkenFrameSetPixel(pFrame, y, x, 0, (unsigned char)val); // set |
811 | 815 |
// |
816 |
+ // |
|
817 |
+ // |
|
818 |
+ // |
|
819 |
+ // |
|
812 | 820 |
// pixel |
813 | 821 |
fscanf(pFile, "%*[ \t]"); // kill space |
814 | 822 |
if (fscanf(pFile, "%7[0-9A-FXa-fx]", pixel) != 1) // read next |
... | ... |
@@ -894,6 +902,10 @@ stBlinkenMovie *BlinkenMovieLoadBml(char *pFilename) |
894 | 902 |
// get fscanf formart string for reading a pixel |
895 | 903 |
sprintf(pixelFormat, "%%%d[0-9A-Fa-f]", chrs > 4 ? 5 : chrs); // read |
896 | 904 |
// |
905 |
+ // |
|
906 |
+ // |
|
907 |
+ // |
|
908 |
+ // |
|
897 | 909 |
// max |
898 | 910 |
// 5 |
899 | 911 |
// chars |
... | ... |
@@ -1599,6 +1611,10 @@ stBlinkenMovie *BlinkenMovieReceive(SOCKET udpSocket, int timeout, |
1599 | 1611 |
timeo.tv_usec = (timeout % 1000) * 1000; |
1600 | 1612 |
if (select(udpSocket + 1, &readFds, NULL, NULL, &timeo) <= 0) // timeout |
1601 | 1613 |
// |
1614 |
+ // |
|
1615 |
+ // |
|
1616 |
+ // |
|
1617 |
+ // |
|
1602 | 1618 |
// or |
1603 | 1619 |
// error |
1604 | 1620 |
break; |
1605 | 1621 |