?? showicon.cpp
字號:
// showicon.cpp : Defines the class behaviors for the application.
//
#include "stdafx.h"
#include "showicon.h"
#include "MainFrm.h"
#include "showiconDoc.h"
#include "showiconView.h"
#ifdef _DEBUG
#define new DEBUG_NEW
#undef THIS_FILE
static char THIS_FILE[] = __FILE__;
#endif
/////////////////////////////////////////////////////////////////////////////
// CShowiconApp
BEGIN_MESSAGE_MAP(CShowiconApp, CWinApp)
//{{AFX_MSG_MAP(CShowiconApp)
ON_COMMAND(ID_APP_ABOUT, OnAppAbout)
// NOTE - the ClassWizard will add and remove mapping macros here.
// DO NOT EDIT what you see in these blocks of generated code!
//}}AFX_MSG_MAP
// Standard file based document commands
ON_COMMAND(ID_FILE_NEW, CWinApp::OnFileNew)
ON_COMMAND(ID_FILE_OPEN, CWinApp::OnFileOpen)
// Standard print setup command
ON_COMMAND(ID_FILE_PRINT_SETUP, CWinApp::OnFilePrintSetup)
END_MESSAGE_MAP()
/////////////////////////////////////////////////////////////////////////////
// CShowiconApp construction
CShowiconApp::CShowiconApp()
{
// TODO: add construction code here,
// Place all significant initialization in InitInstance
}
/////////////////////////////////////////////////////////////////////////////
// The one and only CShowiconApp object
CShowiconApp theApp;
/////////////////////////////////////////////////////////////////////////////
// CShowiconApp initialization
BOOL CShowiconApp::InitInstance()
{
AfxEnableControlContainer();
// Standard initialization
// If you are not using these features and wish to reduce the size
// of your final executable, you should remove from the following
// the specific initialization routines you do not need.
#ifdef _AFXDLL
Enable3dControls(); // Call this when using MFC in a shared DLL
#else
Enable3dControlsStatic(); // Call this when linking to MFC statically
#endif
// Change the registry key under which our settings are stored.
// TODO: You should modify this string to be something appropriate
// such as the name of your company or organization.
SetRegistryKey(_T("Local AppWizard-Generated Applications"));
LoadStdProfileSettings(); // Load standard INI file options (including MRU)
// Register the application's document templates. Document templates
// serve as the connection between documents, frame windows and views.
CSingleDocTemplate* pDocTemplate;
pDocTemplate = new CSingleDocTemplate(
IDR_MAINFRAME,
RUNTIME_CLASS(CShowiconDoc),
RUNTIME_CLASS(CMainFrame), // main SDI frame window
RUNTIME_CLASS(CShowiconView));
AddDocTemplate(pDocTemplate);
// Parse command line for standard shell commands, DDE, file open
CCommandLineInfo cmdInfo;
ParseCommandLine(cmdInfo);
// Dispatch commands specified on the command line
if (!ProcessShellCommand(cmdInfo))
return FALSE;
// The one and only window has been initialized, so show and update it.
m_pMainWnd->ShowWindow(SW_SHOW);
m_pMainWnd->UpdateWindow();
return TRUE;
}
/////////////////////////////////////////////////////////////////////////////
// CAboutDlg dialog used for App About
class CAboutDlg : public CDialog
{
public:
CAboutDlg();
// Dialog Data
//{{AFX_DATA(CAboutDlg)
enum { IDD = IDD_ABOUTBOX };
//}}AFX_DATA
// ClassWizard generated virtual function overrides
//{{AFX_VIRTUAL(CAboutDlg)
protected:
virtual void DoDataExchange(CDataExchange* pDX); // DDX/DDV support
//}}AFX_VIRTUAL
// Implementation
protected:
//{{AFX_MSG(CAboutDlg)
// No message handlers
//}}AFX_MSG
DECLARE_MESSAGE_MAP()
};
CAboutDlg::CAboutDlg() : CDialog(CAboutDlg::IDD)
{
//{{AFX_DATA_INIT(CAboutDlg)
//}}AFX_DATA_INIT
}
void CAboutDlg::DoDataExchange(CDataExchange* pDX)
{
CDialog::DoDataExchange(pDX);
//{{AFX_DATA_MAP(CAboutDlg)
//}}AFX_DATA_MAP
}
BEGIN_MESSAGE_MAP(CAboutDlg, CDialog)
//{{AFX_MSG_MAP(CAboutDlg)
// No message handlers
//}}AFX_MSG_MAP
END_MESSAGE_MAP()
// App command to run the dialog
void CShowiconApp::OnAppAbout()
{
CAboutDlg aboutDlg;
aboutDlg.DoModal();
}
typedef unsigned char Byte1; /*8 bits 1 bytes*/
typedef unsigned short int word1; /*16 bits 2 bytes*/
typedef unsigned int dword1; /*32 bits 4 bytes*/
typedef struct tag1BITMAPFILEHEADER {
word1 bfType1;
dword1 bfSize1;
word1 bfReserved1;
word1 bfReserved2;
dword1 bfoffBits1;
} B1ITMAPFILEHEADER;
typedef struct tag1BITMAPINFOHEADER {
dword1 biSize;
dword1 biWidth;
dword1 biHeight;
word1 biPlanes;
word1 biBitCount;
dword1 biCompress;
dword1 biSizeImage;
dword1 biXPeIsPerMeter;
dword1 biYPeIsPerMeter;
dword1 biCIrUsed;
dword1 biClrImprotant;
} B1ITMAPINFOHEADER ;
typedef struct tagRGBQUAD1 {
Byte1 rgbBlue;
Byte1 rgbGreen;
Byte1 rgbRed;
Byte1 rgbReserved;
} RGBQUAD1;
unsigned char *allArabics;
extern void checkwidth(unsigned char* buffer,int* width);
int iGlobNum = 0;
void loadbmp(char *filename,CDC *pDC,int tt)
{
B1ITMAPFILEHEADER bmfHeader;
B1ITMAPINFOHEADER bmiHeader;
RGBQUAD1 * bmiColor;
FILE *fp1;
FILE *fp;
FILE *fp2;
int bytes_line;
int nColors=1;
fp=fopen("9.txt","a");
fp2=fopen("10.txt","a");
if(fp==NULL)
{printf("error");
return ;}
fp1=fopen(filename,"rb");
if(fp1==NULL)
{printf("error");
return ;}
fread(&bmfHeader.bfType1 ,2, 1, fp1);
fread(&bmfHeader.bfSize1 ,4, 1, fp1);
fread(&bmfHeader.bfReserved1 ,2,1,fp1);
fread(&bmfHeader.bfReserved2 ,2,1,fp1);
fread(&bmfHeader.bfoffBits1 ,4,1,fp1);
iGlobNum++;
fread(&bmiHeader, sizeof(bmiHeader), 1, fp1);
nColors<<=bmiHeader.biBitCount;
bmiColor=(RGBQUAD1 *)malloc(nColors * 4);
fread(bmiColor, 4, nColors, fp1);
//bytes_line=(bmiHeader.biWidth)/8;
int n1=0,n2;
n1=bmiHeader.biWidth*bmiHeader.biBitCount;
n1=((n1+31)/32)*4;
/*n1/=8;*/
bytes_line=n1;
n1 = (bmiHeader.biWidth*bmiHeader.biBitCount)/8;
n2 = (bmiHeader.biWidth*bmiHeader.biBitCount)%8;
allArabics=(unsigned char *)malloc(bmiHeader.biHeight*bytes_line);
if(allArabics==NULL)
AfxMessageBox("malloc error");
unsigned char * ptr1=(unsigned char * )malloc(bytes_line);
unsigned char _bit[8]={128, 64, 32, 16, 8, 4, 2, 1};
fseek(fp1, bmfHeader.bfoffBits1, SEEK_SET);
for(int i=0; i<bmiHeader.biHeight; i++)
{
int x=100;
unsigned char tempchar=0x00;
fread(ptr1,bytes_line, 1, fp1);
for(int j=0;j<bytes_line;j++)
{
if ( j < n1 )
tempchar = ~*(ptr1+j);
else if ( j == n1 )
{
tempchar = *(ptr1+j)|((1<<(8-n2))-1);
tempchar =~tempchar ;
}
else
tempchar = 0;
*(allArabics+(bmiHeader.biHeight-1-i)*bytes_line+j )= tempchar;
}
for( int j1=0, int i1=0; i1<bmiHeader.biWidth; j1++,i1++)
{
if(!(*(ptr1+i1/8) & _bit[j1%8]) )
pDC->SetPixel( x, 300-i, 0x00230032);
x++;
}
}
#if 1
int fontwidth;
checkwidth((unsigned char *)allArabics,&fontwidth);
if (tt > 0xb0)
fontwidth+=3;
#endif
fprintf(fp,"{0x%x,%d,\n",tt,fontwidth);
//fprintf(fp,"U8 DATA%d={\n",tt,fontwidth);
fprintf(fp2,"%d,%d,DATA%d,\n",bytes_line,bmiHeader.biHeight,tt);
for( i=0;i<bmiHeader.biHeight*bytes_line;i++)
{
if ( i%bytes_line <= (n1-1) )
fprintf(fp,"0x%02x,",*(allArabics+i));
if(((i+1)%bytes_line)==0)
fprintf(fp,"\n");
}
fprintf(fp,"},\n\n");
//fprintf(fp,"};\n\n");
//fprintf(fp2,"\n%d\n",iGlobNum);
free(allArabics);
fclose(fp);
fclose(fp1);
}
void CH_ShowICon(int x,int y,int color,unsigned char name[24][4],CDC *pDC)
{unsigned char _bit[8]={128, 64, 32, 16, 8, 4, 2, 1};
for(int i=0; i<24; i++)
for(int j=0;j<32;j++)
{
if((name[i][j/8]&_bit[j%8]))
pDC->SetPixel(x+j,y+i ,RGB(255,0,0));}
}
void CH1_ShowICon(int x,int y,int color,unsigned char name[30][5],CDC *pDC)
{unsigned char _bit[8]={128, 64, 32, 16, 8, 4, 2, 1};
for(int i=0; i<40; i++)
for(int j=0;j<40;j++)
{
if((name[i][j/8]&_bit[j%8]))
pDC->SetPixel(x+j,y+i ,RGB(255,0,255));}
}
/////////////////////////////////////////////////////////////////////////////// CShowiconApp message handlers
void checkwidth(unsigned char *buffer,int* width)
{
int i,j,bwidth=0;
for ( i = 0 ; i < 24 ; i++ )
{
for ( j = 0 ; j < 24 ; j++ )
{
if ( (buffer[i*4+j/8]>>(7-j%8))&0x01 )
bwidth = bwidth<j?j:bwidth;
}
}
*width = bwidth+1;
}
?? 快捷鍵說明
復制代碼
Ctrl + C
搜索代碼
Ctrl + F
全屏模式
F11
切換主題
Ctrl + Shift + D
顯示快捷鍵
?
增大字號
Ctrl + =
減小字號
Ctrl + -