Mercurial > mm7
comparison Render.cpp @ 2128:0d0aa7c1ccdd
Savegame_screenshot continue
author | Ritor1 |
---|---|
date | Sat, 28 Dec 2013 00:32:08 +0600 |
parents | 400f3db2e4e5 |
children | 651b24553ae9 |
comparison
equal
deleted
inserted
replaced
2127:400f3db2e4e5 | 2128:0d0aa7c1ccdd |
---|---|
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 |
2623 Src.bpp = 8; | 2623 Src.bpp = 8; |
2624 Src.hdpi = 75; | 2624 Src.hdpi = 75; |
2625 Src.vdpi = 75; | 2625 Src.vdpi = 75; |
2626 v27.planes = 3; | 2626 v27.planes = 3; |
2627 v27.palette_info = 1; | 2627 v27.palette_info = 1; |
2628 memcpy(data_buff, &Src, 1u); | 2628 memcpy(data_buff, &Src, 1); |
2629 v8 = (char *)v8 + 1; | 2629 v8 = (char *)v8 + 1; |
2630 memcpy(v8, &Src.version, 1u); | 2630 memcpy(v8, &Src.version, 1); |
2631 v8 = (char *)v8 + 1; | 2631 v8 = (char *)v8 + 1; |
2632 memcpy(v8, &Src.encoding, 1u); | 2632 memcpy(v8, &Src.encoding, 1); |
2633 v8 = (char *)v8 + 1; | 2633 v8 = (char *)v8 + 1; |
2634 memcpy(v8, &Src.bpp, 1u); | 2634 memcpy(v8, &Src.bpp, 1); |
2635 v8 = (char *)v8 + 1; | 2635 v8 = (char *)v8 + 1; |
2636 memcpy(v8, &Src.left, 2u); | 2636 memcpy(v8, &Src.left, 2); |
2637 v8 = (char *)v8 + 2; | 2637 v8 = (char *)v8 + 2; |
2638 memcpy(v8, &Src.up, 2u); | 2638 memcpy(v8, &Src.up, 2); |
2639 v8 = (char *)v8 + 2; | 2639 v8 = (char *)v8 + 2; |
2640 memcpy(v8, &Src.right, 2u); | 2640 memcpy(v8, &Src.right, 2); |
2641 v8 = (char *)v8 + 2; | 2641 v8 = (char *)v8 + 2; |
2642 memcpy(v8, &Src.bottom, 2u); | 2642 memcpy(v8, &Src.bottom, 2); |
2643 v8 = (char *)v8 + 2; | 2643 v8 = (char *)v8 + 2; |
2644 memcpy(v8, &Src.hdpi, 2); | 2644 memcpy(v8, &Src.hdpi, 2); |
2645 v8 = (char *)v8 + 2; | 2645 v8 = (char *)v8 + 2; |
2646 memcpy(v8, &Src.vdpi, 2); | 2646 memcpy(v8, &Src.vdpi, 2); |
2647 v8 = (char *)v8 + 2; | 2647 v8 = (char *)v8 + 2; |
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 v26 = 3 * pitch; | 2665 v26 = 3 * pitch; |
2666 v23 = 2 * wight; | 2666 v23 = 2 * wight; |
2667 v11 = picture_data; | 2667 v11 = picture_data; |
2668 v24 = (int)picture_data; | 2668 v24 = (int)picture_data; |
2669 for ( v25 = heidth; v25; v25-- ) | 2669 for ( v25 = heidth; v25; v25-- ) |
2676 for ( uint i = 0; i < wight; i++ ) | 2676 for ( uint i = 0; i < wight; i++ ) |
2677 { | 2677 { |
2678 lineRGB[i] = (signed int)(this->uTargetRMask & *line_pictute_data) >> (this->uTargetGBits + this->uTargetBBits + this->uTargetRBits - 8); | 2678 lineRGB[i] = (signed int)(this->uTargetRMask & *line_pictute_data) >> (this->uTargetGBits + this->uTargetBBits + this->uTargetRBits - 8); |
2679 lineG[i] = (signed int)(this->uTargetGMask & *line_pictute_data) >> ( this->uTargetBBits + this->uTargetGBits- 8); | 2679 lineG[i] = (signed int)(this->uTargetGMask & *line_pictute_data) >> ( this->uTargetBBits + this->uTargetGBits- 8); |
2680 lineB[i] = (this->uTargetBMask & *line_pictute_data) << (8 - this->uTargetBBits); | 2680 lineB[i] = (this->uTargetBMask & *line_pictute_data) << (8 - this->uTargetBBits); |
2681 line_pictute_data += 2; | |
2681 } | 2682 } |
2682 } | 2683 } |
2683 for ( i = 0; i < v26; v9 = (char *)v9 + 1 ) | 2684 for ( i = 0; i < v26; v9 = (char *)v9 + 1 ) |
2684 { | 2685 { |
2685 pict_byte = lineRGB [i]; | 2686 pict_byte = lineRGB[i]; |
2686 for ( test_byte = 1; test_byte < 63; ++test_byte ) | 2687 for ( test_byte = 1; test_byte < 63; ++test_byte ) |
2687 { | 2688 { |
2688 v15 = i + test_byte; | 2689 v15 = i + test_byte; |
2689 if ( *((char *)lineRGB + v15) != pict_byte ) | 2690 if ( lineRGB[v15] != pict_byte ) |
2690 break; | 2691 break; |
2691 if ( !(v15 % pitch) ) | 2692 if ( !(v15 % pitch) ) |
2692 break; | 2693 break; |
2693 } | 2694 } |
2694 if ( i + test_byte > v26 ) | 2695 if ( i + test_byte > v26 ) |
2700 v9 = (char *)v9 + 1; | 2701 v9 = (char *)v9 + 1; |
2701 } | 2702 } |
2702 memcpy(v9, &pict_byte, 1); | 2703 memcpy(v9, &pict_byte, 1); |
2703 i += test_byte; | 2704 i += test_byte; |
2704 } | 2705 } |
2705 v11 +=wight ; | 2706 v11 += wight; |
2706 v10 = pitch; | 2707 //v10 = pitch; |
2707 } | 2708 } |
2708 } | 2709 } |
2709 free(lineRGB); | 2710 free(lineRGB); |
2710 *(int *)packed_size = (char *)v9 - data_buff; | 2711 *(int *)packed_size = (char *)v9 - data_buff; |
2711 } | 2712 } |
2712 | 2713 |
2713 //----- (0049F8B5) -------------------------------------------------------- | 2714 //----- (0049F8B5) -------------------------------------------------------- |
2714 FILE *Render::SavePCXImage(const char *Filename, char *pPixels, int width, int height) | 2715 FILE *Render::SavePCXImage(const char *Filename, unsigned short* picture_data, int width, int height) |
2715 { | 2716 { |
2716 //Render *v5; // esi@1 | 2717 //Render *v5; // esi@1 |
2717 FILE *result; // eax@1 | 2718 FILE *result; // eax@1 |
2718 FILE *pOutFile; // edi@4 | 2719 FILE *pOutFile; // edi@4 |
2719 int v8; // ecx@5 | 2720 //int v8; // ecx@5 |
2720 int v9; // eax@5 | 2721 unsigned short* v9; // eax@5 |
2721 int v10; // eax@7 | 2722 int v10; // eax@7 |
2722 //int v11; // ecx@9 | 2723 //int v11; // ecx@9 |
2723 signed int v12; // eax@12 | 2724 signed int v12; // eax@12 |
2724 char v13; // zf@21 | 2725 char v13; // zf@21 |
2725 char v14[56]; // [sp+4h] [bp-A0h]@4 | 2726 char v14[56]; // [sp+4h] [bp-A0h]@4 |
2729 int v18; // [sp+74h] [bp-30h]@5 | 2730 int v18; // [sp+74h] [bp-30h]@5 |
2730 char *v19; // [sp+78h] [bp-2Ch]@5 | 2731 char *v19; // [sp+78h] [bp-2Ch]@5 |
2731 int image_width; // [sp+7Ch] [bp-28h]@5 | 2732 int image_width; // [sp+7Ch] [bp-28h]@5 |
2732 PCXHeader_1 header1; // [sp+80h] [bp-24h]@4 | 2733 PCXHeader_1 header1; // [sp+80h] [bp-24h]@4 |
2733 PCXHeader_2 header2; // [sp+90h] [bp-14h]@4 | 2734 PCXHeader_2 header2; // [sp+90h] [bp-14h]@4 |
2734 void *for_rad; // [sp+98h] [bp-Ch]@4 | 2735 char *lineRGB; // [sp+98h] [bp-Ch]@4 |
2735 int new_width; // [sp+9Ch] [bp-8h]@2 | 2736 int pitch; // [sp+9Ch] [bp-8h]@2 |
2736 char *for_blue; // [sp+A0h] [bp-4h]@8 | 2737 char *lineB; // [sp+A0h] [bp-4h]@8 |
2738 char *lineG; | |
2739 unsigned short* line_pictute_data; | |
2740 byte test_byte; | |
2741 char v43; | |
2737 | 2742 |
2738 int num_r_bits = 5; | 2743 int num_r_bits = 5; |
2739 int num_g_bits = 6; | 2744 int num_g_bits = 6; |
2740 int num_b_bits = 5; | 2745 int num_b_bits = 5; |
2741 | 2746 |
2745 | 2750 |
2746 result = fopen(Filename, "wb"); | 2751 result = fopen(Filename, "wb"); |
2747 Filename = (const char *)result; | 2752 Filename = (const char *)result; |
2748 if ( result ) | 2753 if ( result ) |
2749 { | 2754 { |
2750 new_width = width; | 2755 pitch = width; |
2751 if ( width & 1 ) | 2756 if ( width & 1 ) |
2752 new_width = width + 1; | 2757 pitch = width + 1; |
2753 header1.left = 0; | 2758 header1.left = 0; |
2754 header1.up = 0; | 2759 header1.up = 0; |
2755 header1.right = width - 1; | 2760 header1.right = width - 1; |
2756 header1.bottom = height - 1; | 2761 header1.bottom = height - 1; |
2757 header2.pitch = new_width; | 2762 header2.pitch = pitch; |
2758 memset(color_map, 0, sizeof(color_map)); | 2763 memset(color_map, 0, sizeof(color_map)); |
2759 header2.reserved = 0; | 2764 header2.reserved = 0; |
2760 memset(v14, 0, sizeof(v14)); | 2765 memset(v14, 0, sizeof(v14)); |
2761 v15 = 0; | 2766 v15 = 0; |
2762 header1.manufacturer = 10; | 2767 header1.manufacturer = 10; |
2782 fwrite(&header2, 1, 1, pOutFile); | 2787 fwrite(&header2, 1, 1, pOutFile); |
2783 fwrite(&header2.planes, 1, 1, pOutFile); | 2788 fwrite(&header2.planes, 1, 1, pOutFile); |
2784 fwrite(&header2.pitch, 2, 1, pOutFile); | 2789 fwrite(&header2.pitch, 2, 1, pOutFile); |
2785 fwrite(&header2.palette_info, 2, 1, pOutFile); | 2790 fwrite(&header2.palette_info, 2, 1, pOutFile); |
2786 fwrite(v14, 0x3Au, 1, pOutFile); | 2791 fwrite(v14, 0x3Au, 1, pOutFile); |
2787 for_rad = malloc(3 * width + 6); | 2792 |
2793 lineRGB = (char *)malloc(3 * (width + 2)); | |
2788 //При сохранении изображения подряд идущие пиксели одинакового цвета объединяются и вместо указания цвета для каждого пикселя | 2794 //При сохранении изображения подряд идущие пиксели одинакового цвета объединяются и вместо указания цвета для каждого пикселя |
2789 //указывается цвет группы пикселей и их количество. | 2795 //указывается цвет группы пикселей и их количество. |
2790 //if ( height > 0 ) | 2796 //if ( height > 0 ) |
2791 //{ | 2797 //{ |
2792 v8 = new_width; | 2798 //v8 = pitch; |
2793 image_width = 3 * new_width; | 2799 image_width = 3 * pitch; |
2794 v17 = 2 * width; | 2800 v17 = 2 * width; |
2795 //v9 = (int)pPixels; | 2801 v9 = picture_data; |
2796 //v19 = pPixels; | 2802 //v19 = pPixels; |
2797 for ( v18 = 0; v18 < height; v18++ )//столбец | 2803 for ( v18 = 0; v18 < height; v18++ )//столбец |
2798 { | 2804 { |
2799 //pPixels = v9; | 2805 line_pictute_data = v9; |
2800 char *for_green = (char *)for_rad + v8; | 2806 lineG = (char *)lineRGB + pitch; |
2801 for_blue = (char *)for_rad + 2 * new_width; | 2807 lineB = (char *)lineRGB + 2 * pitch; |
2802 | 2808 |
2803 for ( v10 = 0; v10 < width; v10++ )//строка | 2809 for ( int i = 0; i < width; i++ )//строка |
2804 { | 2810 { |
2805 *((char *)for_rad + v10) = (signed int)(r_mask & *(short *)pPixels) >> (num_g_bits + num_b_bits + num_r_bits - 8); | 2811 lineRGB[i] = (signed int)(r_mask & *line_pictute_data) >> (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); | 2812 lineG[i] = (signed int)(g_mask & *line_pictute_data) >> (num_b_bits + num_g_bits - 8); |
2807 for_blue[v10] = (b_mask & *(char *)pPixels) << (8 - num_b_bits); | 2813 lineB[i] = (b_mask & *line_pictute_data) << (8 - num_b_bits); |
2808 pPixels += 2; | 2814 line_pictute_data += 2; |
2809 } | 2815 } |
2810 | 2816 test_byte = 1; |
2811 for ( int i = 0; (signed int)i < image_width; i++ )// += BYTE3(pPixels) ) | 2817 for ( int i = 0; (signed int)i < image_width; i += test_byte )// += BYTE3(pPixels) ) |
2812 { | 2818 { |
2813 unsigned char test_byte = *((char *)for_rad + i); | 2819 unsigned char pic_byte = lineRGB[i]; |
2814 //for ( BYTE3(pPixels) = 1; BYTE3(pPixels) < 0x3F; ++BYTE3(pPixels) ) | 2820 //for ( BYTE3(pPixels) = 1; BYTE3(pPixels) < 0x3F; ++BYTE3(pPixels) ) |
2815 for ( int j = 1; j < 0x3F; ++j )// расчёт количества одинаковых цветов | 2821 for ( test_byte; test_byte < 63; ++test_byte )// расчёт количества одинаковых цветов |
2816 { | 2822 { |
2817 v12 = (signed int)&for_blue[BYTE3(pPixels)]; | 2823 v12 = i + test_byte; |
2818 if ( *((char *)for_rad + j) != test_byte ) | 2824 if ( lineRGB[v12] != pic_byte ) |
2819 break; | 2825 break; |
2820 if ( !(v12 % new_width) ) | 2826 if ( !(v12 % pitch) ) |
2821 break; | 2827 break; |
2822 } | 2828 } |
2823 if ( (signed int)&for_blue[BYTE3(pPixels)] > image_width ) | 2829 if ( i + test_byte > image_width ) |
2824 BYTE3(pPixels) = 3 * new_width - (char)i; | 2830 test_byte = 3 * pitch - i; |
2825 if ( BYTE3(pPixels) > 1 || test_byte >= 0xC0 ) | 2831 if ( test_byte > 1 || pic_byte >= 0xC0 ) |
2826 { | 2832 { |
2827 BYTE3(for_green) = BYTE3(pPixels) | 0xC0;//тест-байт объединения | 2833 v43 = test_byte | 0xC0;//тест-байт объединения |
2828 fwrite((char *)&for_green + 3, 1, 1, pOutFile); | 2834 fwrite(&v43, 1, 1, pOutFile); |
2829 } | 2835 } |
2830 fwrite((char *)&Filename + 3, 1, 1, pOutFile); | 2836 fwrite(&pic_byte, 1, 1, pOutFile); |
2831 } | 2837 } |
2832 //v9 = (int)&v19[v17]; | 2838 v9 += width; |
2833 //v19 += v17; | 2839 //v19 += v17; |
2834 pPixels += v17; | 2840 //pPixels += v17; |
2835 v8 = new_width; | 2841 //v8 = pitch; |
2836 } | 2842 } |
2837 //} | 2843 //} |
2838 free(for_rad); | 2844 free(lineRGB); |
2839 result = (FILE *)fclose(pOutFile); | 2845 result = (FILE *)fclose(pOutFile); |
2840 } | 2846 } |
2841 return result; | 2847 return result; |
2842 } | 2848 } |
2843 | 2849 |