Mercurial > mm7
diff Render.cpp @ 2127:400f3db2e4e5
Screenshot continue
author | Ritor1 |
---|---|
date | Fri, 27 Dec 2013 17:52:31 +0600 |
parents | 3eab5530cc94 |
children | 0d0aa7c1ccdd |
line wrap: on
line diff
--- a/Render.cpp Thu Dec 26 22:58:54 2013 +0000 +++ b/Render.cpp Fri Dec 27 17:52:31 2013 +0600 @@ -2572,13 +2572,13 @@ //----- (0049F5A2) -------------------------------------------------------- void Render::PackPCXpicture( unsigned short* picture_data, int wight, int heidth, void *data_buff, int max_buff_size,unsigned int* packed_size ) - { - Render *v7; // ebx@1 +{ + //Render *v7; // ebx@1 void *v8; // esi@3 void *v9; // esi@3 int v10; // ecx@4 unsigned short* v11; // eax@4 - int v12; // eax@6 + //int v12; // eax@6 int v13; // eax@8 int v14; // ecx@8 signed int v15; // eax@11 @@ -2603,7 +2603,7 @@ byte test_byte; unsigned char pict_byte; - v7 = this; + //v7 = this; pitch = wight; if ( wight & 1 ) pitch = wight + 1; @@ -2641,19 +2641,19 @@ v8 = (char *)v8 + 2; memcpy(v8, &Src.bottom, 2u); v8 = (char *)v8 + 2; - memcpy(v8, &Src.hdpi, 2u); + memcpy(v8, &Src.hdpi, 2); v8 = (char *)v8 + 2; - memcpy(v8, &Src.vdpi, 2u); + memcpy(v8, &Src.vdpi, 2); v8 = (char *)v8 + 2; memcpy(v8, &v20, 0x30u); v8 = (char *)v8 + 48; memcpy(v8, &v27, 1u); v8 = (char *)v8 + 1; - memcpy(v8, &v27.planes, 1u); + memcpy(v8, &v27.planes, 1); v8 = (char *)v8 + 1; - memcpy(v8, &v27.pitch, 2u); + memcpy(v8, &v27.pitch, 2); v8 = (char *)v8 + 2; - memcpy(v8, &v27.palette_info, 2u); + memcpy(v8, &v27.palette_info, 2); v8 = (char *)v8 + 2; memcpy(v8, &v18, 0x3Au); v9 = (char *)v8 + 58; @@ -2662,78 +2662,64 @@ if ( heidth > 0 ) { v10 = pitch; - v25 = heidth; v26 = 3 * pitch; v23 = 2 * wight; v11 = picture_data; v24 = (int)picture_data; - while ( 1 ) + for ( v25 = heidth; v25; v25-- ) { line_pictute_data = v11; - v12 = 0; - i = 0; if ( wight > 0 ) { lineG = (char *)lineRGB + pitch; lineB = (char *)lineRGB + 2 * pitch; - do + for ( uint i = 0; i < wight; i++ ) { - lineRGB[v12] = (signed int)(v7->uTargetRMask & *line_pictute_data) >> (v7->uTargetGBits + v7->uTargetBBits + v7->uTargetRBits - 8); - lineG[v12] = (signed int)(v7->uTargetGMask & *line_pictute_data) >> ( v7->uTargetBBits + v7->uTargetGBits- 8); - lineB[v12] = (v7->uTargetBMask & *line_pictute_data) << (8 - v7->uTargetBBits); - - v12++; + lineRGB[i] = (signed int)(this->uTargetRMask & *line_pictute_data) >> (this->uTargetGBits + this->uTargetBBits + this->uTargetRBits - 8); + lineG[i] = (signed int)(this->uTargetGMask & *line_pictute_data) >> ( this->uTargetBBits + this->uTargetGBits- 8); + lineB[i] = (this->uTargetBMask & *line_pictute_data) << (8 - this->uTargetBBits); } - while ( v12 < wight ); } for ( i = 0; i < v26; v9 = (char *)v9 + 1 ) { - test_byte = 1; pict_byte = lineRGB [i]; - do + for ( test_byte = 1; test_byte < 63; ++test_byte ) { v15 = i + test_byte; if ( *((char *)lineRGB + v15) != pict_byte ) break; if ( !(v15 % pitch) ) break; - ++test_byte; } - while ( test_byte < 0x3Fu ); if ( i + test_byte > v26 ) test_byte = 3 * pitch - i; - if ( test_byte > 1u || pict_byte >= 0xC0u ) + if ( test_byte > 1 || pict_byte >= 192 ) { v43 = test_byte | 0xC0; - memcpy(v9, &v43, 1u); + memcpy(v9, &v43, 1); v9 = (char *)v9 + 1; } - memcpy(v9, &pict_byte, 1u); + memcpy(v9, &pict_byte, 1); i += test_byte; } v11 +=wight ; - v16 = v25-- == 1; - - if ( v16 ) - break; v10 = pitch; } } free(lineRGB); *(int *)packed_size = (char *)v9 - data_buff; - } //----- (0049F8B5) -------------------------------------------------------- -FILE *Render::SavePCXImage(const char *Filename, char *a3, int a4, int a5) +FILE *Render::SavePCXImage(const char *Filename, char *pPixels, int width, int height) { //Render *v5; // esi@1 FILE *result; // eax@1 - FILE *v7; // edi@4 + FILE *pOutFile; // edi@4 int v8; // ecx@5 int v9; // eax@5 int v10; // eax@7 - int v11; // ecx@9 + //int v11; // ecx@9 signed int v12; // eax@12 char v13; // zf@21 char v14[56]; // [sp+4h] [bp-A0h]@4 @@ -2742,25 +2728,33 @@ int v17; // [sp+70h] [bp-34h]@5 int v18; // [sp+74h] [bp-30h]@5 char *v19; // [sp+78h] [bp-2Ch]@5 - int v20; // [sp+7Ch] [bp-28h]@5 + int image_width; // [sp+7Ch] [bp-28h]@5 PCXHeader_1 header1; // [sp+80h] [bp-24h]@4 PCXHeader_2 header2; // [sp+90h] [bp-14h]@4 - void *ptr; // [sp+98h] [bp-Ch]@4 - int v24; // [sp+9Ch] [bp-8h]@2 - char *i; // [sp+A0h] [bp-4h]@8 + void *for_rad; // [sp+98h] [bp-Ch]@4 + int new_width; // [sp+9Ch] [bp-8h]@2 + char *for_blue; // [sp+A0h] [bp-4h]@8 + + int num_r_bits = 5; + int num_g_bits = 6; + int num_b_bits = 5; + + int r_mask = 0xF800; + int g_mask = 0x7E0; + int b_mask = 0x1F; result = fopen(Filename, "wb"); Filename = (const char *)result; if ( result ) { - v24 = a4; - if ( a4 & 1 ) - v24 = a4 + 1; + new_width = width; + if ( width & 1 ) + new_width = width + 1; header1.left = 0; header1.up = 0; - header1.right = a4 - 1; - header1.bottom = a5 - 1; - header2.pitch = v24; + header1.right = width - 1; + header1.bottom = height - 1; + header2.pitch = new_width; memset(color_map, 0, sizeof(color_map)); header2.reserved = 0; memset(v14, 0, sizeof(v14)); @@ -2773,88 +2767,76 @@ header1.vdpi = 75; header2.planes = 3; header2.palette_info = 1; - fwrite(&header1, 1u, 1u, (FILE *)Filename); - v7 = (FILE *)Filename; - fwrite(&header1.version, 1u, 1u, (FILE *)Filename); - fwrite(&header1.encoding, 1u, 1u, v7); - fwrite(&header1.bpp, 1u, 1u, v7); - fwrite(&header1.left, 2u, 1u, v7); - fwrite(&header1.up, 2u, 1u, v7); - fwrite(&header1.right, 2u, 1u, v7); - fwrite(&header1.bottom, 2u, 1u, v7); - fwrite(&header1.hdpi, 2u, 1u, v7); - fwrite(&header1.vdpi, 2u, 1u, v7); - fwrite(color_map, 0x30u, 1u, v7); - fwrite(&header2, 1u, 1u, v7); - fwrite(&header2.planes, 1u, 1u, v7); - fwrite(&header2.pitch, 2u, 1u, v7); - fwrite(&header2.palette_info, 2u, 1u, v7); - fwrite(v14, 0x3Au, 1u, v7); - ptr = malloc(3 * a4 + 6); - if ( a5 > 0 ) - { - v8 = v24; - v18 = a5; - v20 = 3 * v24; - v17 = 2 * a4; - v9 = (int)a3; - v19 = a3; - while ( 1 ) - { - a5 = v9; - v10 = 0; - if ( a4 > 0 ) + fwrite(&header1, 1, 1, (FILE *)Filename); + pOutFile = (FILE *)Filename; + fwrite(&header1.version, 1, 1, (FILE *)Filename); + fwrite(&header1.encoding, 1, 1, pOutFile); + fwrite(&header1.bpp, 1, 1, pOutFile); + fwrite(&header1.left, 2, 1, pOutFile); + fwrite(&header1.up, 2, 1, pOutFile); + fwrite(&header1.right, 2, 1, pOutFile); + fwrite(&header1.bottom, 2, 1, pOutFile); + fwrite(&header1.hdpi, 2, 1, pOutFile); + fwrite(&header1.vdpi, 2, 1, pOutFile); + fwrite(color_map, 0x30u, 1, pOutFile); + fwrite(&header2, 1, 1, pOutFile); + fwrite(&header2.planes, 1, 1, pOutFile); + fwrite(&header2.pitch, 2, 1, pOutFile); + fwrite(&header2.palette_info, 2, 1, pOutFile); + fwrite(v14, 0x3Au, 1, pOutFile); + for_rad = malloc(3 * width + 6); + //При сохранении изображения подряд идущие пиксели одинакового цвета объединяются и вместо указания цвета для каждого пикселя + //указывается цвет группы пикселей и их количество. + //if ( height > 0 ) + //{ + v8 = new_width; + image_width = 3 * new_width; + v17 = 2 * width; + //v9 = (int)pPixels; + //v19 = pPixels; + for ( v18 = 0; v18 < height; v18++ )//столбец + { + //pPixels = v9; + char *for_green = (char *)for_rad + v8; + for_blue = (char *)for_rad + 2 * new_width; + + for ( v10 = 0; v10 < width; v10++ )//строка + { + *((char *)for_rad + v10) = (signed int)(r_mask & *(short *)pPixels) >> (num_g_bits + num_b_bits + num_r_bits - 8); + for_green[v10] = (signed int)(g_mask & *(short *)pPixels) >> (num_b_bits + num_g_bits - 8); + for_blue[v10] = (b_mask & *(char *)pPixels) << (8 - num_b_bits); + pPixels += 2; + } + + for ( int i = 0; (signed int)i < image_width; i++ )// += BYTE3(pPixels) ) + { + unsigned char test_byte = *((char *)for_rad + i); + //for ( BYTE3(pPixels) = 1; BYTE3(pPixels) < 0x3F; ++BYTE3(pPixels) ) + for ( int j = 1; j < 0x3F; ++j )// расчёт количества одинаковых цветов { - a3 = (char *)ptr + v8; - i = (char *)ptr + 2 * v24; - do - { - *((char *)ptr + v10) = (signed int)(this->uTargetRMask & *(short *)a5) >> (LOBYTE(this->uTargetGBits) - + LOBYTE(this->uTargetBBits) - + this->uTargetRBits - - 8); - a3[v10] = (signed int)(this->uTargetGMask & *(short *)a5) >> (LOBYTE(this->uTargetBBits) - + LOBYTE(this->uTargetGBits) - - 8); - v11 = a5; - a5 += 2; - i[v10++] = (this->uTargetBMask & *(char *)v11) << (8 - LOBYTE(this->uTargetBBits)); - } - while ( v10 < a4 ); + v12 = (signed int)&for_blue[BYTE3(pPixels)]; + if ( *((char *)for_rad + j) != test_byte ) + break; + if ( !(v12 % new_width) ) + break; } - for ( i = 0; (signed int)i < v20; i += BYTE3(a5) ) + if ( (signed int)&for_blue[BYTE3(pPixels)] > image_width ) + BYTE3(pPixels) = 3 * new_width - (char)i; + if ( BYTE3(pPixels) > 1 || test_byte >= 0xC0 ) { - BYTE3(a5) = 1; - BYTE3(Filename) = *((char *)ptr + (int)i); - do - { - v12 = (signed int)&i[BYTE3(a5)]; - if ( *((char *)ptr + v12) != BYTE3(Filename) ) - break; - if ( !(v12 % v24) ) - break; - ++BYTE3(a5); - } - while ( BYTE3(a5) < 0x3Fu ); - if ( (signed int)&i[BYTE3(a5)] > v20 ) - BYTE3(a5) = 3 * v24 - (char)i; - if ( BYTE3(a5) > 1u || BYTE3(Filename) >= 0xC0u ) - { - BYTE3(a3) = BYTE3(a5) | 0xC0; - fwrite((char *)&a3 + 3, 1u, 1u, v7); - } - fwrite((char *)&Filename + 3, 1u, 1u, v7); + BYTE3(for_green) = BYTE3(pPixels) | 0xC0;//тест-байт объединения + fwrite((char *)&for_green + 3, 1, 1, pOutFile); } - v9 = (int)&v19[v17]; - v13 = v18-- == 1; - v19 += v17; - if ( v13 ) - break; - v8 = v24; - } - } - free(ptr); - result = (FILE *)fclose(v7); + fwrite((char *)&Filename + 3, 1, 1, pOutFile); + } + //v9 = (int)&v19[v17]; + //v19 += v17; + pPixels += v17; + v8 = new_width; + } + //} + free(for_rad); + result = (FILE *)fclose(pOutFile); } return result; }