BMP-ASCII-ASSEMBLE

Source: Internet
Author: User

In the screen.txtfile, extract 2 bytes, then upload them to the 16th segment, and then paste the BMP file into llk.bmp.

Screen.txt file format:

A88897c02424...

Hexadecimal notation (hexadecimal notation ):

A8 88 97 C0 24 24

The font color, the font color, the font color, and the font color ......

 

//////////////////////////////////////// //////////////////////////////////////// //////////////////////////////////////// ///////////////////////////////

/// // Main. CPP /////////////////////////////////////// //////////

# Include <stdio. h>
# Include <stdlib. h>
# Include <windows. h>

Int main (void)
{
// ASCII
File * fpascii = fopen ("screen.txt", "RT ");
If (fpascii = NULL)
{
Printf ("the ASCII file token is missing! /N ");
Return false;
}

// BMP
File * fpbmp = fopen ("llk.bmp", "WB + ");
If (fpbmp = NULL)
{
Printf ("loss of the BMP file upload! /N ");
Return false;
}
 
Byte header800_600 [] = {0x42, 0x4d, 0x36, 0xf9, 0x15, 0x00, 0x00, 0x00,
0x00, 0x00, 0x36, 0x00, 0x00, 0x00, 0x28, 0x00,
0x00, 0x00, 0x20, 0x03, 0x00, 0x00, 0x58, 0x02,
0x00, 0x00, 0x01, 0x00, 0x18, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0xf9, 0x15, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00 };
 

Byte header200_200 [] = {0x42, 0x4d, 0xf8, 0xd4, 0x01, 0x00, 0x00, 0x00,
0x00, 0x00, 0x36, 0x00, 0x00, 0x00, 0x28, 0x00,
0x00, 0x00, 0xc8, 0x00, 0x00, 0x00, 0xc8, 0x00,
0x00, 0x00, 0x01, 0x00, 0x18, 0x00, 0x00, 0x00,
0x00, 0x00, 0xc2, 0xd4, 0x01, 0x00, 0x12, 0x0b,
0x00, 0x00, 0x12, 0x0b, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00 };
// Upload BMP File Header
Fwrite (header800_600, sizeof (byte), 54, fpbmp );
 
Byte Buf [3] = {0x00 };

Int I;

// Printf ("Buf [0] = % x/N", Buf [0]);
// For (I = 0; I <= 10; I ++)
While (! Feof (fpbmp ))
{
Fread (BUF, 1, 2, fpascii );

// Buf [0] handling
If (BUF [0] = '0 ')
Buf [0] = 0x00;

If (BUF [0] = '1 ')
Buf [0] = 0x01;

If (BUF [0] = '2 ')
Buf [0] = 0x02;
 
If (BUF [0] = '3 ')
Buf [0] = 0x03;
 
If (BUF [0] = '4 ')
Buf [0] = 0x04;

If (BUF [0] = '5 ')
Buf [0] = 0x05;

If (BUF [0] = '6 ')
Buf [0] = 0x06;

If (BUF [0] = '7 ')
Buf [0] = 0x07;
 
If (BUF [0] = '8 ')
Buf [0] = 0x08;
 
If (BUF [0] = '9 ')
Buf [0] = 0x09;

If (BUF [0] = 'A' | Buf [0] = 'A ')
Buf [0] = 0xa;

If (BUF [0] = 'B' | Buf [0] = 'B ')
Buf [0] = 0xb;

If (BUF [0] = 'C' | Buf [0] = 'C ')
Buf [0] = 0xc;

If (BUF [0] = 'D' | Buf [0] = 'D ')
Buf [0] = 0xd;

If (BUF [0] = 'E' | Buf [0] = 'E ')
Buf [0] = 0xe;
 
If (BUF [0] = 'F' | Buf [0] = 'F ')
Buf [0] = 0xf;
 

// Buf [1] handling
If (BUF [1] = '0 ')
Buf [1] = 0x00;

If (BUF [1] = '1 ')
Buf [1] = 0x01;

If (BUF [1] = '2 ')
Buf [1] = 0x02;
 
If (BUF [1] = '3 ')
Buf [1] = 0x03;
 
If (BUF [1] = '4 ')
Buf [1] = 0x04;
 
If (BUF [1] = '5 ')
Buf [1] = 0x05;

If (BUF [1] = '6 ')
Buf [1] = 0x06;

If (BUF [1] = '7 ')
Buf [1] = 0x07;
 
If (BUF [1] = '8 ')
Buf [1] = 0x08;
 
If (BUF [1] = '9 ')
Buf [1] = 0x09;

If (BUF [1] = 'A' | Buf [1] = 'A ')
Buf [1] = 0xa;

If (BUF [1] = 'B' | Buf [1] = 'B ')
Buf [1] = 0xb;

If (BUF [1] = 'C' | Buf [1] = 'C ')
Buf [1] = 0xc;
 
If (BUF [1] = 'D' | Buf [1] = 'D ')
Buf [1] = 0xd;
 
If (BUF [1] = 'E' | Buf [1] = 'E ')
Buf [1] = 0xe;
 
If (BUF [1] = 'F' | Buf [1] = 'F ')
Buf [1] = 0xf;

// Printf ("% x", Buf [0]);
// Printf ("% x", Buf [1]);
Buf [0] = (BUF [0] <4) + Buf [1];
// Printf ("% x/N", Buf [0]);
Fwrite (BUF, 1, 1, fpbmp );
// I ++;
}

Fclose (fpascii );
Fclose (fpbmp );

Return true;
 
}

//////////////////////////////////////// //// // EOF ///////////////////////// ////////////////////////////////////

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.