comparison Render.cpp @ 2127:400f3db2e4e5

Screenshot continue
author Ritor1
date Fri, 27 Dec 2013 17:52:31 +0600
parents 3eab5530cc94
children 0d0aa7c1ccdd
comparison
equal deleted inserted replaced
2126:a2da7afb41b4 2127:400f3db2e4e5
2570 } 2570 }
2571 // 4EFA84: using guessed type int dword_4EFA84; 2571 // 4EFA84: using guessed type int dword_4EFA84;
2572 2572
2573 //----- (0049F5A2) -------------------------------------------------------- 2573 //----- (0049F5A2) --------------------------------------------------------
2574 void Render::PackPCXpicture( unsigned short* picture_data, int wight, int heidth, void *data_buff, int max_buff_size,unsigned int* packed_size ) 2574 void Render::PackPCXpicture( unsigned short* picture_data, int wight, int heidth, void *data_buff, int max_buff_size,unsigned int* packed_size )
2575 { 2575 {
2576 Render *v7; // ebx@1 2576 //Render *v7; // ebx@1
2577 void *v8; // esi@3 2577 void *v8; // esi@3
2578 void *v9; // esi@3 2578 void *v9; // esi@3
2579 int v10; // ecx@4 2579 int v10; // ecx@4
2580 unsigned short* v11; // eax@4 2580 unsigned short* v11; // eax@4
2581 int v12; // eax@6 2581 //int v12; // eax@6
2582 int v13; // eax@8 2582 int v13; // eax@8
2583 int v14; // ecx@8 2583 int v14; // ecx@8
2584 signed int v15; // eax@11 2584 signed int v15; // eax@11
2585 char v16; // zf@20 2585 char v16; // zf@20
2586 int result; // eax@21 2586 int result; // eax@21
2601 int i; // [sp+B4h] [bp-4h]@6 2601 int i; // [sp+B4h] [bp-4h]@6
2602 unsigned short* line_pictute_data; 2602 unsigned short* line_pictute_data;
2603 byte test_byte; 2603 byte test_byte;
2604 unsigned char pict_byte; 2604 unsigned char pict_byte;
2605 2605
2606 v7 = this; 2606 //v7 = this;
2607 pitch = wight; 2607 pitch = wight;
2608 if ( wight & 1 ) 2608 if ( wight & 1 )
2609 pitch = wight + 1; 2609 pitch = wight + 1;
2610 Src.left = 0; 2610 Src.left = 0;
2611 Src.up = 0; 2611 Src.up = 0;
2639 v8 = (char *)v8 + 2; 2639 v8 = (char *)v8 + 2;
2640 memcpy(v8, &Src.right, 2u); 2640 memcpy(v8, &Src.right, 2u);
2641 v8 = (char *)v8 + 2; 2641 v8 = (char *)v8 + 2;
2642 memcpy(v8, &Src.bottom, 2u); 2642 memcpy(v8, &Src.bottom, 2u);
2643 v8 = (char *)v8 + 2; 2643 v8 = (char *)v8 + 2;
2644 memcpy(v8, &Src.hdpi, 2u); 2644 memcpy(v8, &Src.hdpi, 2);
2645 v8 = (char *)v8 + 2; 2645 v8 = (char *)v8 + 2;
2646 memcpy(v8, &Src.vdpi, 2u); 2646 memcpy(v8, &Src.vdpi, 2);
2647 v8 = (char *)v8 + 2; 2647 v8 = (char *)v8 + 2;
2648 memcpy(v8, &v20, 0x30u); 2648 memcpy(v8, &v20, 0x30u);
2649 v8 = (char *)v8 + 48; 2649 v8 = (char *)v8 + 48;
2650 memcpy(v8, &v27, 1u); 2650 memcpy(v8, &v27, 1u);
2651 v8 = (char *)v8 + 1; 2651 v8 = (char *)v8 + 1;
2652 memcpy(v8, &v27.planes, 1u); 2652 memcpy(v8, &v27.planes, 1);
2653 v8 = (char *)v8 + 1; 2653 v8 = (char *)v8 + 1;
2654 memcpy(v8, &v27.pitch, 2u); 2654 memcpy(v8, &v27.pitch, 2);
2655 v8 = (char *)v8 + 2; 2655 v8 = (char *)v8 + 2;
2656 memcpy(v8, &v27.palette_info, 2u); 2656 memcpy(v8, &v27.palette_info, 2);
2657 v8 = (char *)v8 + 2; 2657 v8 = (char *)v8 + 2;
2658 memcpy(v8, &v18, 0x3Au); 2658 memcpy(v8, &v18, 0x3Au);
2659 v9 = (char *)v8 + 58; 2659 v9 = (char *)v8 + 58;
2660 2660
2661 lineRGB = (char*)malloc(3 * (wight + 2)); 2661 lineRGB = (char*)malloc(3 * (wight + 2));
2662 if ( heidth > 0 ) 2662 if ( heidth > 0 )
2663 { 2663 {
2664 v10 = pitch; 2664 v10 = pitch;
2665 v25 = heidth;
2666 v26 = 3 * pitch; 2665 v26 = 3 * pitch;
2667 v23 = 2 * wight; 2666 v23 = 2 * wight;
2668 v11 = picture_data; 2667 v11 = picture_data;
2669 v24 = (int)picture_data; 2668 v24 = (int)picture_data;
2670 while ( 1 ) 2669 for ( v25 = heidth; v25; v25-- )
2671 { 2670 {
2672 line_pictute_data = v11; 2671 line_pictute_data = v11;
2673 v12 = 0;
2674 i = 0;
2675 if ( wight > 0 ) 2672 if ( wight > 0 )
2676 { 2673 {
2677 lineG = (char *)lineRGB + pitch; 2674 lineG = (char *)lineRGB + pitch;
2678 lineB = (char *)lineRGB + 2 * pitch; 2675 lineB = (char *)lineRGB + 2 * pitch;
2679 do 2676 for ( uint i = 0; i < wight; i++ )
2680 { 2677 {
2681 lineRGB[v12] = (signed int)(v7->uTargetRMask & *line_pictute_data) >> (v7->uTargetGBits + v7->uTargetBBits + v7->uTargetRBits - 8); 2678 lineRGB[i] = (signed int)(this->uTargetRMask & *line_pictute_data) >> (this->uTargetGBits + this->uTargetBBits + this->uTargetRBits - 8);
2682 lineG[v12] = (signed int)(v7->uTargetGMask & *line_pictute_data) >> ( v7->uTargetBBits + v7->uTargetGBits- 8); 2679 lineG[i] = (signed int)(this->uTargetGMask & *line_pictute_data) >> ( this->uTargetBBits + this->uTargetGBits- 8);
2683 lineB[v12] = (v7->uTargetBMask & *line_pictute_data) << (8 - v7->uTargetBBits); 2680 lineB[i] = (this->uTargetBMask & *line_pictute_data) << (8 - this->uTargetBBits);
2684
2685 v12++;
2686 } 2681 }
2687 while ( v12 < wight );
2688 } 2682 }
2689 for ( i = 0; i < v26; v9 = (char *)v9 + 1 ) 2683 for ( i = 0; i < v26; v9 = (char *)v9 + 1 )
2690 { 2684 {
2691 test_byte = 1;
2692 pict_byte = lineRGB [i]; 2685 pict_byte = lineRGB [i];
2693 do 2686 for ( test_byte = 1; test_byte < 63; ++test_byte )
2694 { 2687 {
2695 v15 = i + test_byte; 2688 v15 = i + test_byte;
2696 if ( *((char *)lineRGB + v15) != pict_byte ) 2689 if ( *((char *)lineRGB + v15) != pict_byte )
2697 break; 2690 break;
2698 if ( !(v15 % pitch) ) 2691 if ( !(v15 % pitch) )
2699 break; 2692 break;
2700 ++test_byte;
2701 } 2693 }
2702 while ( test_byte < 0x3Fu );
2703 if ( i + test_byte > v26 ) 2694 if ( i + test_byte > v26 )
2704 test_byte = 3 * pitch - i; 2695 test_byte = 3 * pitch - i;
2705 if ( test_byte > 1u || pict_byte >= 0xC0u ) 2696 if ( test_byte > 1 || pict_byte >= 192 )
2706 { 2697 {
2707 v43 = test_byte | 0xC0; 2698 v43 = test_byte | 0xC0;
2708 memcpy(v9, &v43, 1u); 2699 memcpy(v9, &v43, 1);
2709 v9 = (char *)v9 + 1; 2700 v9 = (char *)v9 + 1;
2710 } 2701 }
2711 memcpy(v9, &pict_byte, 1u); 2702 memcpy(v9, &pict_byte, 1);
2712 i += test_byte; 2703 i += test_byte;
2713 } 2704 }
2714 v11 +=wight ; 2705 v11 +=wight ;
2715 v16 = v25-- == 1;
2716
2717 if ( v16 )
2718 break;
2719 v10 = pitch; 2706 v10 = pitch;
2720 } 2707 }
2721 } 2708 }
2722 free(lineRGB); 2709 free(lineRGB);
2723 *(int *)packed_size = (char *)v9 - data_buff; 2710 *(int *)packed_size = (char *)v9 - data_buff;
2724
2725 } 2711 }
2726 2712
2727 //----- (0049F8B5) -------------------------------------------------------- 2713 //----- (0049F8B5) --------------------------------------------------------
2728 FILE *Render::SavePCXImage(const char *Filename, char *a3, int a4, int a5) 2714 FILE *Render::SavePCXImage(const char *Filename, char *pPixels, int width, int height)
2729 { 2715 {
2730 //Render *v5; // esi@1 2716 //Render *v5; // esi@1
2731 FILE *result; // eax@1 2717 FILE *result; // eax@1
2732 FILE *v7; // edi@4 2718 FILE *pOutFile; // edi@4
2733 int v8; // ecx@5 2719 int v8; // ecx@5
2734 int v9; // eax@5 2720 int v9; // eax@5
2735 int v10; // eax@7 2721 int v10; // eax@7
2736 int v11; // ecx@9 2722 //int v11; // ecx@9
2737 signed int v12; // eax@12 2723 signed int v12; // eax@12
2738 char v13; // zf@21 2724 char v13; // zf@21
2739 char v14[56]; // [sp+4h] [bp-A0h]@4 2725 char v14[56]; // [sp+4h] [bp-A0h]@4
2740 __int16 v15; // [sp+3Ch] [bp-68h]@4 2726 __int16 v15; // [sp+3Ch] [bp-68h]@4
2741 char color_map[48]; // [sp+40h] [bp-64h]@4 2727 char color_map[48]; // [sp+40h] [bp-64h]@4
2742 int v17; // [sp+70h] [bp-34h]@5 2728 int v17; // [sp+70h] [bp-34h]@5
2743 int v18; // [sp+74h] [bp-30h]@5 2729 int v18; // [sp+74h] [bp-30h]@5
2744 char *v19; // [sp+78h] [bp-2Ch]@5 2730 char *v19; // [sp+78h] [bp-2Ch]@5
2745 int v20; // [sp+7Ch] [bp-28h]@5 2731 int image_width; // [sp+7Ch] [bp-28h]@5
2746 PCXHeader_1 header1; // [sp+80h] [bp-24h]@4 2732 PCXHeader_1 header1; // [sp+80h] [bp-24h]@4
2747 PCXHeader_2 header2; // [sp+90h] [bp-14h]@4 2733 PCXHeader_2 header2; // [sp+90h] [bp-14h]@4
2748 void *ptr; // [sp+98h] [bp-Ch]@4 2734 void *for_rad; // [sp+98h] [bp-Ch]@4
2749 int v24; // [sp+9Ch] [bp-8h]@2 2735 int new_width; // [sp+9Ch] [bp-8h]@2
2750 char *i; // [sp+A0h] [bp-4h]@8 2736 char *for_blue; // [sp+A0h] [bp-4h]@8
2737
2738 int num_r_bits = 5;
2739 int num_g_bits = 6;
2740 int num_b_bits = 5;
2741
2742 int r_mask = 0xF800;
2743 int g_mask = 0x7E0;
2744 int b_mask = 0x1F;
2751 2745
2752 result = fopen(Filename, "wb"); 2746 result = fopen(Filename, "wb");
2753 Filename = (const char *)result; 2747 Filename = (const char *)result;
2754 if ( result ) 2748 if ( result )
2755 { 2749 {
2756 v24 = a4; 2750 new_width = width;
2757 if ( a4 & 1 ) 2751 if ( width & 1 )
2758 v24 = a4 + 1; 2752 new_width = width + 1;
2759 header1.left = 0; 2753 header1.left = 0;
2760 header1.up = 0; 2754 header1.up = 0;
2761 header1.right = a4 - 1; 2755 header1.right = width - 1;
2762 header1.bottom = a5 - 1; 2756 header1.bottom = height - 1;
2763 header2.pitch = v24; 2757 header2.pitch = new_width;
2764 memset(color_map, 0, sizeof(color_map)); 2758 memset(color_map, 0, sizeof(color_map));
2765 header2.reserved = 0; 2759 header2.reserved = 0;
2766 memset(v14, 0, sizeof(v14)); 2760 memset(v14, 0, sizeof(v14));
2767 v15 = 0; 2761 v15 = 0;
2768 header1.manufacturer = 10; 2762 header1.manufacturer = 10;
2771 header1.bpp = 8; 2765 header1.bpp = 8;
2772 header1.hdpi = 75; 2766 header1.hdpi = 75;
2773 header1.vdpi = 75; 2767 header1.vdpi = 75;
2774 header2.planes = 3; 2768 header2.planes = 3;
2775 header2.palette_info = 1; 2769 header2.palette_info = 1;
2776 fwrite(&header1, 1u, 1u, (FILE *)Filename); 2770 fwrite(&header1, 1, 1, (FILE *)Filename);
2777 v7 = (FILE *)Filename; 2771 pOutFile = (FILE *)Filename;
2778 fwrite(&header1.version, 1u, 1u, (FILE *)Filename); 2772 fwrite(&header1.version, 1, 1, (FILE *)Filename);
2779 fwrite(&header1.encoding, 1u, 1u, v7); 2773 fwrite(&header1.encoding, 1, 1, pOutFile);
2780 fwrite(&header1.bpp, 1u, 1u, v7); 2774 fwrite(&header1.bpp, 1, 1, pOutFile);
2781 fwrite(&header1.left, 2u, 1u, v7); 2775 fwrite(&header1.left, 2, 1, pOutFile);
2782 fwrite(&header1.up, 2u, 1u, v7); 2776 fwrite(&header1.up, 2, 1, pOutFile);
2783 fwrite(&header1.right, 2u, 1u, v7); 2777 fwrite(&header1.right, 2, 1, pOutFile);
2784 fwrite(&header1.bottom, 2u, 1u, v7); 2778 fwrite(&header1.bottom, 2, 1, pOutFile);
2785 fwrite(&header1.hdpi, 2u, 1u, v7); 2779 fwrite(&header1.hdpi, 2, 1, pOutFile);
2786 fwrite(&header1.vdpi, 2u, 1u, v7); 2780 fwrite(&header1.vdpi, 2, 1, pOutFile);
2787 fwrite(color_map, 0x30u, 1u, v7); 2781 fwrite(color_map, 0x30u, 1, pOutFile);
2788 fwrite(&header2, 1u, 1u, v7); 2782 fwrite(&header2, 1, 1, pOutFile);
2789 fwrite(&header2.planes, 1u, 1u, v7); 2783 fwrite(&header2.planes, 1, 1, pOutFile);
2790 fwrite(&header2.pitch, 2u, 1u, v7); 2784 fwrite(&header2.pitch, 2, 1, pOutFile);
2791 fwrite(&header2.palette_info, 2u, 1u, v7); 2785 fwrite(&header2.palette_info, 2, 1, pOutFile);
2792 fwrite(v14, 0x3Au, 1u, v7); 2786 fwrite(v14, 0x3Au, 1, pOutFile);
2793 ptr = malloc(3 * a4 + 6); 2787 for_rad = malloc(3 * width + 6);
2794 if ( a5 > 0 ) 2788 //При сохранении изображения подряд идущие пиксели одинакового цвета объединяются и вместо указания цвета для каждого пикселя
2795 { 2789 //указывается цвет группы пикселей и их количество.
2796 v8 = v24; 2790 //if ( height > 0 )
2797 v18 = a5; 2791 //{
2798 v20 = 3 * v24; 2792 v8 = new_width;
2799 v17 = 2 * a4; 2793 image_width = 3 * new_width;
2800 v9 = (int)a3; 2794 v17 = 2 * width;
2801 v19 = a3; 2795 //v9 = (int)pPixels;
2802 while ( 1 ) 2796 //v19 = pPixels;
2803 { 2797 for ( v18 = 0; v18 < height; v18++ )//столбец
2804 a5 = v9; 2798 {
2805 v10 = 0; 2799 //pPixels = v9;
2806 if ( a4 > 0 ) 2800 char *for_green = (char *)for_rad + v8;
2801 for_blue = (char *)for_rad + 2 * new_width;
2802
2803 for ( v10 = 0; v10 < width; v10++ )//строка
2804 {
2805 *((char *)for_rad + v10) = (signed int)(r_mask & *(short *)pPixels) >> (num_g_bits + num_b_bits + num_r_bits - 8);
2806 for_green[v10] = (signed int)(g_mask & *(short *)pPixels) >> (num_b_bits + num_g_bits - 8);
2807 for_blue[v10] = (b_mask & *(char *)pPixels) << (8 - num_b_bits);
2808 pPixels += 2;
2809 }
2810
2811 for ( int i = 0; (signed int)i < image_width; i++ )// += BYTE3(pPixels) )
2812 {
2813 unsigned char test_byte = *((char *)for_rad + i);
2814 //for ( BYTE3(pPixels) = 1; BYTE3(pPixels) < 0x3F; ++BYTE3(pPixels) )
2815 for ( int j = 1; j < 0x3F; ++j )// расчёт количества одинаковых цветов
2807 { 2816 {
2808 a3 = (char *)ptr + v8; 2817 v12 = (signed int)&for_blue[BYTE3(pPixels)];
2809 i = (char *)ptr + 2 * v24; 2818 if ( *((char *)for_rad + j) != test_byte )
2810 do 2819 break;
2811 { 2820 if ( !(v12 % new_width) )
2812 *((char *)ptr + v10) = (signed int)(this->uTargetRMask & *(short *)a5) >> (LOBYTE(this->uTargetGBits) 2821 break;
2813 + LOBYTE(this->uTargetBBits)
2814 + this->uTargetRBits
2815 - 8);
2816 a3[v10] = (signed int)(this->uTargetGMask & *(short *)a5) >> (LOBYTE(this->uTargetBBits)
2817 + LOBYTE(this->uTargetGBits)
2818 - 8);
2819 v11 = a5;
2820 a5 += 2;
2821 i[v10++] = (this->uTargetBMask & *(char *)v11) << (8 - LOBYTE(this->uTargetBBits));
2822 }
2823 while ( v10 < a4 );
2824 } 2822 }
2825 for ( i = 0; (signed int)i < v20; i += BYTE3(a5) ) 2823 if ( (signed int)&for_blue[BYTE3(pPixels)] > image_width )
2824 BYTE3(pPixels) = 3 * new_width - (char)i;
2825 if ( BYTE3(pPixels) > 1 || test_byte >= 0xC0 )
2826 { 2826 {
2827 BYTE3(a5) = 1; 2827 BYTE3(for_green) = BYTE3(pPixels) | 0xC0;//тест-байт объединения
2828 BYTE3(Filename) = *((char *)ptr + (int)i); 2828 fwrite((char *)&for_green + 3, 1, 1, pOutFile);
2829 do
2830 {
2831 v12 = (signed int)&i[BYTE3(a5)];
2832 if ( *((char *)ptr + v12) != BYTE3(Filename) )
2833 break;
2834 if ( !(v12 % v24) )
2835 break;
2836 ++BYTE3(a5);
2837 }
2838 while ( BYTE3(a5) < 0x3Fu );
2839 if ( (signed int)&i[BYTE3(a5)] > v20 )
2840 BYTE3(a5) = 3 * v24 - (char)i;
2841 if ( BYTE3(a5) > 1u || BYTE3(Filename) >= 0xC0u )
2842 {
2843 BYTE3(a3) = BYTE3(a5) | 0xC0;
2844 fwrite((char *)&a3 + 3, 1u, 1u, v7);
2845 }
2846 fwrite((char *)&Filename + 3, 1u, 1u, v7);
2847 } 2829 }
2848 v9 = (int)&v19[v17]; 2830 fwrite((char *)&Filename + 3, 1, 1, pOutFile);
2849 v13 = v18-- == 1; 2831 }
2850 v19 += v17; 2832 //v9 = (int)&v19[v17];
2851 if ( v13 ) 2833 //v19 += v17;
2852 break; 2834 pPixels += v17;
2853 v8 = v24; 2835 v8 = new_width;
2854 } 2836 }
2855 } 2837 //}
2856 free(ptr); 2838 free(for_rad);
2857 result = (FILE *)fclose(v7); 2839 result = (FILE *)fclose(pOutFile);
2858 } 2840 }
2859 return result; 2841 return result;
2860 } 2842 }
2861 2843
2862 //----- (0049FBCD) -------------------------------------------------------- 2844 //----- (0049FBCD) --------------------------------------------------------