📄 maingui.cpp
字号:
#include "stdio.h"
#include "stdlib.h"
#include <string.h>
#include <stdarg.h>
#include <math.h>
#include <windows.h>
#include <conio.h>
#include "Resource.h"
#include "MainGUI.h"
#include <commctrl.h>
HINSTANCE MainInstance;
extern HWND MainWindow;
tImage *Image;
tImage *TempPic;
tImage *LoadedImage;
tLayer *Layer;
tLayer *AktLayer;
tLayer *TempLayer;
unsigned char ShowChannel;
void ReFreshPic(HWND hWnd,tImage *Image)
{
long I,K,C;
long *Pic;
unsigned long Mask;
HDC hDC;
hDC=GetDC(GetDlgItem(hWnd,IDC_TEXWINDOW));
Pic=(long*)Image->Data;
if(ShowChannel==0) Mask=0x000000FF;
if(ShowChannel==1) Mask=0x0000FF00;
if(ShowChannel==2) Mask=0x00FF0000;
if(ShowChannel==3) Mask=0xFF000000;
if(ShowChannel==4) Mask=0xFFFFFFFF;
if(ShowChannel==5) Mask=0x00FFFFFF;
for(K=0;K<Image->YSize;K++)
{
for(I=0;I<Image->XSize;I++)
{
if(ShowChannel==3)
{
C=(((*(Pic+K*Image->XSize+I))&Mask)>>24)&0xFF;
C=(C<<16)|(C<<8)|C;
SetPixel(hDC,I,K,C);
} else {
SetPixel(hDC,I,K,(*(Pic+K*Image->XSize+I))&Mask);
}
}
}
ReleaseDC(GetDlgItem(hWnd,IDC_TEXWINDOW),hDC);
}
void ReFreshPicTiled(HWND hWnd)
{
long I,K,XM,YM;
long *Pic;
unsigned long Mask;
HDC hDC;
hDC=GetDC(GetDlgItem(hWnd,IDC_TEXWINDOW));
Pic=(long*)Image->Data;
XM=Image->XSize/2;
YM=Image->YSize/2;
if(ShowChannel==0) Mask=0x000000FF;
if(ShowChannel==1) Mask=0x0000FF00;
if(ShowChannel==2) Mask=0x00FF0000;
if(ShowChannel==3) Mask=0xFF000000;
if(ShowChannel==4) Mask=0xFFFFFFFF;
if(ShowChannel==5) Mask=0x00FFFFFF;
for(K=0;K<Image->YSize;K++)
{
for(I=0;I<Image->XSize;I++)
{
SetPixel(hDC,I,K,(*(Pic+((K+YM)%Image->YSize)*Image->XSize+(I+XM)%Image->XSize))&Mask);
}
}
ReleaseDC(GetDlgItem(hWnd,IDC_TEXWINDOW),hDC);
}
void InitPreview()
{
TempPic=CopyImage(Image);
}
void Preview()
{
ReFreshPic(MainWindow,TempPic);
DestroyImage(TempPic);
}
tImage *GetFatherImage(tLayer *Start,tLayer *Akt)
{
if(Akt==Start) return(BlankImage);
while(Start->Next!=Akt) Start=Start->Next;
return(Start->Image);
}
void GetShitCharFileName(HWND LB_Parent_Hwnd,char *MyString) // L鋎t ne .dat
{
OPENFILENAME ofn; /* common dialog box structure */
char szDirName[MAX_PATH]; /* directory string */
char szFile[4096]; /* filename string */
char szFileTitle[4096]; /* filename string */
long I,K,M;
tLayer *Temp;
/*
hinst = (HINSTANCE)GetWindowLong(hwnd, GWL_HINSTANCE);
*/
/*
Obtain the system directory name and store it in szDirName.
*/
GetSystemDirectory(szDirName, sizeof(szDirName));
/*
Place the terminating null character in the szFile.
*/
szFile[0] = '\0';
/*
Set the members of the OPENFILENAME structure.
*/
memset(&ofn, 0, sizeof(ofn));
ofn.lStructSize = sizeof(OPENFILENAME);
ofn.hwndOwner = LB_Parent_Hwnd;
ofn.lpstrTitle = "Select Picture -[ !! Max 8 Characters !! ]- \0";
ofn.lpstrFilter = "TEXditor Files (*.tcm)\0*.tcm\0All files (*.*)\0*.*\0\0";
ofn.lpstrCustomFilter = NULL;
ofn.nFilterIndex = 1;
ofn.lpstrFile = szFile;
ofn.nMaxFile = 2048;
ofn.lpstrFileTitle = szFileTitle;
ofn.nMaxFileTitle = 2048;
ofn.lpstrInitialDir = ".\0";
ofn.Flags = OFN_EXPLORER | OFN_PATHMUSTEXIST | OFN_FILEMUSTEXIST;
/*
Display the Open dialog box.
*/
if (GetOpenFileName(&ofn))
{
char *path = ofn.lpstrFile;
char *fname = ofn.lpstrFileTitle;
char *outp;
if(strlen(fname)<=12)
memcpy(MyString,fname,9);
};
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -