【文件属性】:
文件名称:手机图片浏览器
文件大小:505KB
文件格式:RAR
更新时间:2015-11-04 03:07:55
手机图片浏览
// PhonePictureDlg.cpp : implementation file
//
#include "stdafx.h"
#include "PhonePicture.h"
#include "PhonePictureDlg.h"
#ifdef _DEBUG
#define new DEBUG_NEW
#undef THIS_FILE
static char THIS_FILE[] = __FILE__;
#endif
/////////////////////////////////////////////////////////////////////////////
// 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)
//}}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()
/////////////////////////////////////////////////////////////////////////////
// CPhonePictureDlg dialog
CPhonePictureDlg::CPhonePictureDlg(CWnd* pParent /*=NULL*/)
: CDialog(CPhonePictureDlg::IDD, pParent)
{
//{{AFX_DATA_INIT(CPhonePictureDlg)
m_PicWidth = 0;
m_PicHigh = 0;
m_address = _T("");
m_MouseX = 0;
m_MouseY = 0;
m_PicEditAdd = _T("");
//}}AFX_DATA_INIT
// Note that LoadIcon does not require a subsequent DestroyIcon in Win32
m_hIcon = AfxGetApp()->LoadIcon(IDR_MAINFRAME);
}
void CPhonePictureDlg::DoDataExchange(CDataExchange* pDX)
{
CDialog::DoDataExchange(pDX);
//{{AFX_DATA_MAP(CPhonePictureDlg)
DDX_Control(pDX, IDC_COMBO1, m_buchang);
DDX_Control(pDX, IDC_PICTYPE, m_pictype);
DDX_Text(pDX, IDC_WIDTH, m_PicWidth);
DDX_Text(pDX, IDC_HIGH, m_PicHigh);
DDV_MinMaxInt(pDX, m_PicHigh, 0, 1000);
DDX_Control(pDX, IDC_IMAGE1, m_image);
DDX_Control(pDX, IDC_SCROLLBAR_Horizontal, m_HORScrollBar);
DDX_Control(pDX, IDC_SCROLLBAR_Vertical, m_VERScrollBar);
DDX_Text(pDX, IDC_ADDRESS, m_address);
DDX_Control(pDX, IDC_SCROLLBAR_Horizontal2, m_width);
DDX_Control(pDX, IDC_SCROLLBAR_Horizontal3, m_high);
DDX_Text(pDX, IDC_EDIT1, m_MouseX);
DDX_Text(pDX, IDC_EDIT2, m_MouseY);
DDX_Control(pDX, IDC_SCROLLBAR_Horizontal4, m_PicNum);
DDX_Text(pDX, IDC_EDIT3, m_PicEditAdd);
//}}AFX_DATA_MAP
}
BEGIN_MESSAGE_MAP(CPhonePictureDlg, CDialog)
//{{AFX_MSG_MAP(CPhonePictureDlg)
ON_WM_SYSCOMMAND()
ON_WM_PAINT()
ON_WM_QUERYDRAGICON()
ON_COMMAND(IDC_FILE_EXIT, OnFileExit)
ON_EN_CHANGE(IDC_WIDTH, OnChangeWidth)
ON_EN_CHANGE(IDC_HIGH, OnChangeHigh)
ON_COMMAND(IDC_FILE_OPEN, OnFileOpen)
ON_COMMAND(IDC_FILE_SAVE, OnFileSave)
ON_COMMAND(IDC_FILE_SAVEAS, OnFileSaveas)
ON_UPDATE_COMMAND_UI(IDC_FILE_SAVE, OnUpdateFileSave)
ON_CBN_SELCHANGE(IDC_PICTYPE, OnSelchangePictype)
ON_WM_TIMER()
ON_CBN_SELCHANGE(IDC_COMBO1, OnSelchangeCombo1)
ON_EN_CHANGE(IDC_ADDRESS, OnChangeAddress)
ON_COMMAND(IDC_PICTURE_EDITLAYOUT, OnPictureEditlayout)
ON_COMMAND(IDC_PICTURE_EDITLAYIN, OnPictureEditlayin)
ON_COMMAND(IDC_CUT, OnCut)
ON_COMMAND(IDC_PASE, OnPase)
ON_BN_CLICKED(IDC_RADIO1, OnRadio1)
ON_BN_CLICKED(IDC_RADIO2, OnRadio2)
ON_BN_CLICKED(IDC_RADIO3, OnRadio3)
ON_BN_CLICKED(IDC_RADIO4, OnRadio4)
//}}AFX_MSG_MAP
END_MESSAGE_MAP()
/////////////////////////////////////////////////////////////////////////////
// CPhonePictureDlg message handlers
BOOL CPhonePictureDlg::OnInitDialog()
{
CDialog::OnInitDialog();
// Add "About..." menu item to system menu.
// IDM_ABOUTBOX must be in the system command range.
ASSERT((IDM_ABOUTBOX & 0xFFF0) == IDM_ABOUTBOX);
ASSERT(IDM_ABOUTBOX < 0xF000);
CMenu* pSysMenu = GetSystemMenu(FALSE);
if (pSysMenu != NULL)
{
CString strAboutMenu;
strAboutMenu.LoadString(IDS_ABOUTBOX);
if (!strAboutMenu.IsEmpty())
{
pSysMenu->AppendMenu(MF_SEPARATOR);
pSysMenu->AppendMenu(MF_STRING, IDM_ABOUTBOX, strAboutMenu);
}
}
// Set the icon for this dialog. The framework does this automatically
// when the application's main window is not a dialog
SetIcon(m_hIcon, TRUE); // Set big icon
SetIcon(m_hIcon, FALSE); // Set small icon
CPoint point;
// TODO: Add extra initialization here
m_pictype.SetWindowText("16貫廬꽈");
PICTYPE=5;
m_PicHigh=220;
m_PicWidth=176;
PicHigh=220;
PicWidth=176;
UpdateData(false);
STEPX=STEPY=0;
buchang=0;
m_address="0x0";
m_width.SetMax(1560);
m_width.SetValue(540);
m_high.SetMax (560);
m_high.SetValue(540);
SelectPic=0;
LoadRosoure();
fileready=0;
needadd=0;
STARTADD=0x9a47bc;
needpack=0;
return TRUE;
}
void CPhonePictureDlg::OnSysCommand(UINT nID, LPARAM lParam)
{
if ((nID & 0xFFF0) == IDM_ABOUTBOX)
{
CAboutDlg dlgAbout;
dlgAbout.DoModal();
}
else
{
CDialog::OnSysCommand(nID, lParam);
}
}
// If you add a minimize button to your dialog, you will need the code below
// to draw the icon. For MFC applications using the document/view model,
// this is automatically done for you by the framework.
void CPhonePictureDlg::OnPaint()
{
if (IsIconic())
{
CPaintDC dc(this); // device context for painting
SendMessage(WM_ICONERASEBKGND, (WPARAM) dc.GetSafeHdc(), 0);
// Center icon in client rectangle
int cxIcon = GetSystemMetrics(SM_CXICON);
int cyIcon = GetSystemMetrics(SM_CYICON);
CRect rect;
GetClientRect(▭);
int x = (rect.Width() - cxIcon + 1) / 2;
int y = (rect.Height() - cyIcon + 1) / 2;
// Draw the icon
dc.DrawIcon(x, y, m_hIcon);
}
else
{
CDialog::OnPaint();
}
}
// The system calls this to obtain the cursor to display while the user drags
// the minimized window.
HCURSOR CPhonePictureDlg::OnQueryDragIcon()
{
return (HCURSOR) m_hIcon;
}
void CPhonePictureDlg::OnOK()
{
// TODO: Add extra validation here
CDialog::OnOK();
}
void CPhonePictureDlg::OnFileExit()
{
// TODO: Add your command handler code here
OnOK() ;
}
BOOL CPhonePictureDlg::LoadRosoure()
{
HRSRC hRsrc = FindResource(NULL, MAKEINTRESOURCE(IDR_BMPTITLE), TEXT("BIN"));
if (NULL == hRsrc)
return FALSE;
//삿혤栗都돨댕鬼
DWORD dwSize = SizeofResource(NULL, hRsrc);
if (0 == dwSize)
return FALSE;
//속潼栗都
HGLOBAL hGlobal = LoadResource(NULL, hRsrc);
if (NULL == hGlobal)
return FALSE;
//傑땍栗都
LPVOID pBuffer = LockResource(hGlobal);
if (NULL == pBuffer)
return FALSE;
else
{
BmpTitleBuf=(char*)pBuffer;
BmpTitleSize=dwSize;
}
loadpictab();
return TRUE;
}
void CPhonePictureDlg::OnChangeWidth()
{
UpdateData(true);
PicWidth=m_PicWidth;
PicXNum=312/PicWidth;
}
void CPhonePictureDlg::OnChangeHigh()
{
UpdateData(true);
PicHigh=m_PicHigh;
PicYNum=258/PicHigh;
}
void CPhonePictureDlg::OnFileOpen()
{
char szFileFilter[]=
"BIN File(*.Bin)|*.Bin|"
"SKD File(*.SKD)|*.SKD|"
"BMP File(*.BMP)|*.BMP|"
"BMP File(*.DAT)|*.DAT|"
"All File(*.*)|*.*|";
CFileDialog dlg(TRUE,NULL,NULL,OFN_HIDEREADONLY,szFileFilter);
if(dlg.DoModal()==IDOK)
{
FileName=dlg.GetPathName();
//뭐芚CFile뚤蹶
CFile File(FileName,CFile::modeRead);
//롸토뻠녑혐,댕鬼槨匡숭댕鬼
FileSize=File.GetLength();
FileBuf = (char*) malloc(FileSize);
File.ReadHuge(FileBuf,FileSize);
File.Close();
m_HORScrollBar.SetMax(FileSize/65536) ;
fileready=1;
int k;
switch(PICTYPE)
{
case 0:
k=1;
break;
case 1:
k=1;
break;
case 2:
k=1;
break;
case 3:
k=1;
break;
case 4:
k=1;
break;
case 5:
k=2;
break;
case 6:
k=3;
break;
case 7:
k=3;
break;
case 8:
k=3;
break;
case 9:
k=2;
break;
}
m_VERScrollBar.SetMax(65536/k);
SetTimeOn(50);
}
}
void CPhonePictureDlg::OnFileSave()
{
// TODO: Add your command handler code here
CFile File(FileName, CFile::modeCreate |
CFile::modeWrite);
File.WriteHuge(FileBuf,FileSize);
File.Close();
}
void CPhonePictureDlg::OnFileSaveas()
{
char szFileFilter[]=
"BIN File(*.Bin)|*.Bin|"
"SKD File(*.SKD)|*.SKD|"
"All File(*.*)|*.*|";
CFileDialog SelectFile(FALSE,NULL,"",OFN_HIDEREADONLY,szFileFilter,NULL);
SelectFile.m_ofn.lpstrTitle="朞嶝狼괏닸돨匡숭";
if(SelectFile.DoModal()==IDOK)
{
FileName=SelectFile.GetPathName();
CFile File(FileName, CFile::modeCreate |
CFile::modeWrite);
File.WriteHuge(FileBuf,FileSize);
File.Close();
}
}
BEGIN_EVENTSINK_MAP(CPhonePictureDlg, CDialog)
//{{AFX_EVENTSINK_MAP(CPhonePictureDlg)
ON_EVENT(CPhonePictureDlg, IDC_IMAGE1, -607 /* MouseUp */, OnMouseUpImage1, VTS_I2 VTS_I2 VTS_R4 VTS_R4)
ON_EVENT(CPhonePictureDlg, IDC_IMAGE1, -606 /* MouseMove */, OnMouseMoveImage1, VTS_I2 VTS_I2 VTS_R4 VTS_R4)
ON_EVENT(CPhonePictureDlg, IDC_SCROLLBAR_Horizontal, 2 /* Change */, OnChangeSCROLLBARHorizontal, VTS_NONE)
ON_EVENT(CPhonePictureDlg, IDC_SCROLLBAR_Vertical, 2 /* Change */, OnChangeSCROLLBARVertical, VTS_NONE)
ON_EVENT(CPhonePictureDlg, IDC_SCROLLBAR_Horizontal, 7 /* Scroll */, OnScrollSCROLLBARHorizontal, VTS_NONE)
ON_EVENT(CPhonePictureDlg, IDC_SCROLLBAR_Vertical, 7 /* Scroll */, OnScrollSCROLLBARVertical, VTS_NONE)
ON_EVENT(CPhonePictureDlg, IDC_SCROLLBAR_Horizontal2, 2 /* Change */, OnChangeSCROLLBARHorizontal2, VTS_NONE)
ON_EVENT(CPhonePictureDlg, IDC_SCROLLBAR_Horizontal2, 7 /* Scroll */, OnScrollSCROLLBARHorizontal2, VTS_NONE)
ON_EVENT(CPhonePictureDlg, IDC_SCROLLBAR_Horizontal3, 2 /* Change */, OnChangeSCROLLBARHorizontal3, VTS_NONE)
ON_EVENT(CPhonePictureDlg, IDC_SCROLLBAR_Horizontal3, 7 /* Scroll */, OnScrollSCROLLBARHorizontal3, VTS_NONE)
ON_EVENT(CPhonePictureDlg, IDC_IMAGE1, -601 /* DblClick */, OnDblClickImage1, VTS_DISPATCH)
ON_EVENT(CPhonePictureDlg, IDC_SCROLLBAR_Horizontal4, 2 /* Change */, OnChangeSCROLLBARHorizontal4, VTS_NONE)
ON_EVENT(CPhonePictureDlg, IDC_SCROLLBAR_Horizontal4, 7 /* Scroll */, OnScrollSCROLLBARHorizontal4, VTS_NONE)
ON_EVENT(CPhonePictureDlg, IDC_IMAGE1, 3 /* BeforeDragOver */, OnBeforeDragOverImage1, VTS_DISPATCH VTS_DISPATCH VTS_R4 VTS_R4 VTS_I4 VTS_DISPATCH VTS_I2)
ON_EVENT(CPhonePictureDlg, IDC_SCROLLBAR_Horizontal2, 3 /* BeforeDragOver */, OnBeforeDragOverSCROLLBARHorizontal2, VTS_DISPATCH VTS_DISPATCH VTS_R4 VTS_R4 VTS_I4 VTS_DISPATCH VTS_I2)
//}}AFX_EVENTSINK_MAP
END_EVENTSINK_MAP()
void CPhonePictureDlg::OnMouseUpImage1(short Button, short Shift, float X, float Y)
{
// TODO: Add your control notification handler code here
if(Button==2&&fileready;==1)
{
CMenu *m_pMenu;
CMenu menu;
menu.LoadMenu(IDR_MAIN_MENU);
m_pMenu = menu.GetSubMenu(1);
m_pMenu->TrackPopupMenu(TPM_CENTERALIGN + TPM_LEFTBUTTON,
int(X + 515),int(Y+450) ,this,NULL);
}
}
void CPhonePictureDlg::OnUpdateFileSave(CCmdUI* pCmdUI)
{
}
void CPhonePictureDlg::OnSelchangePictype()
{
PICTYPE=m_pictype.GetCurSel();
int k;
switch(PICTYPE)
{
case 0:
k=1;
break;
case 1:
k=1;
break;
case 2:
k=1;
break;
case 3:
k=1;
break;
case 4:
k=1;
break;
case 5:
k=2;
break;
case 6:
k=3;
break;
case 7:
k=3;
break;
case 8:
k=3;
break;
case 9:
k=2;
break;
}
m_VERScrollBar.SetMax(65536/k);
}
void CPhonePictureDlg::OnMouseMoveImage1(short Button, short Shift, float X, float Y)
{
MousePoint.x=int(X)*4/3;
MousePoint.y=(int)Y*4/3;
m_MouseX= MousePoint.x;
m_MouseY= MousePoint.y;
UpdateData(false);
}
void CPhonePictureDlg::OnChangeSCROLLBARHorizontal()
{
STEPX=m_HORScrollBar.GetValue();
}
void CPhonePictureDlg::OnTimer(UINT nIDEvent)
{
ShowPic();
CDialog::OnTimer(nIDEvent);
}
void CPhonePictureDlg::SetTimeOn(int x)
{
int result=SetTimer(1,x,NULL);
if(result==0)
{
MessageBox("땍珂포갛陋呵겨!.");
}
}
void CPhonePictureDlg::ShowPic()
{
unsigned long add;
add=STEPX*65536+STEPY+buchang;
m_address=Hex2Str(add);
UpdateData(false);
switch(PICTYPE)
{
case 0:
ShowMoneColor(PICTYPE);
break;
case 1:
ShowMoneColor(PICTYPE);
break;
case 2:
ShowMoneColorHH();
break;
case 3:
ShowMoneColorH(PICTYPE);
break;
case 4:
Showcolor(8);
break;
case 5:
Showcolor(16);
break;
case 6:
Showcolor(24);
break;
case 7:
Showcolor(32);
break;
case 8:
Showcolor(22);
break;
case 9:
Showcolor(12);
break;
}
}
void CPhonePictureDlg::Showcolor(int k)//鞫刻16貫꽈貫暠
{
int i,j,p;
unsigned short RGB;
int w,h;
unsigned long color;
unsigned char R,G,B,H;
CBitmap Bitmap,*pOldBitmap;
int x,y;
int pointnum;
short pointcolor;
x=MousePoint.x/PicWidth;
y=MousePoint.y/PicHigh;
BITMAP bm;
CDC MemDC;
CDC *pDC;
unsigned char Data[499200];
PicXNum=1560/PicWidth;
PicYNum=320/PicHigh;
pDC=m_image.GetDC();
Bitmap.LoadBitmap(IDB_BITMAP1);// Bitmap.CreateBitmap(560,320,1,24,NULL);//
//retrieve information about a CBitmap object
Bitmap.GetObject(sizeof(BITMAP),&bm;);
char *gadd;
if(!MemDC.CreateCompatibleDC(pDC))
return ;
pOldBitmap=(CBitmap*)MemDC.SelectObject(&Bitmap;);
for(h=0;hFileSize)
break;
R=*(unsigned char*)(FileBuf+buchang+STEPX*65536+STEPY+(h*PicXNum+w)*(8+(PicWidth*PicHigh))+j*PicWidth+i);
G=*(unsigned char*)(FileBuf+buchang+STEPX*65536+STEPY+(h*PicXNum+w)*(8+(PicWidth*PicHigh))+j*PicWidth+i);
B=*(unsigned char*)(FileBuf+buchang+STEPX*65536+STEPY+(h*PicXNum+w)*(8+(PicWidth*PicHigh))+j*PicWidth+i);
H=0;
break;
break;
case 16:
if(STEPX*65536+STEPY+buchang+(h*PicXNum+w)*2*(PicWidth*PicHigh)+2*j*PicWidth+2*i>FileSize)
break;
gadd=FileBuf+buchang+STEPX*65536+STEPY+(h*PicXNum+w)*2*(PicWidth*PicHigh)+2*j*PicWidth+2*i;
RGB=*(unsigned short*)gadd;
color= ConverColor16t24(RGB);
if(x==w&&y==h&SelectPic;==1)
{
R=0xff-char((color&0x00ff0000;)>>16);
G=0xff-char((color&0x0000ff00;)>>8);
B=0xff-char(color&0x000000ff;);
H=0;
}
else
{
B=char((color&0x00ff0000;)>>16);
G=char((color&0x0000ff00;)>>8);
R=char(color&0x000000ff;);
H=0;
}
break;
case 24:
if(STEPX*65536+STEPY+buchang+(h*PicXNum+w)*3*(PicWidth*PicHigh)+3*j*PicWidth+3*i>FileSize)
break;
R=*(unsigned char*)(FileBuf+buchang+STEPX*65536+STEPY+(h*PicXNum+w)*(8+3*(PicWidth*PicHigh))+3*j*PicWidth+3*i);
G=*(unsigned char*)(FileBuf+buchang+STEPX*65536+STEPY+(h*PicXNum+w)*(8+3*(PicWidth*PicHigh))+3*j*PicWidth+3*i+1);
B=*(unsigned char*)(FileBuf+buchang+STEPX*65536+STEPY+(h*PicXNum+w)*(8+3*(PicWidth*PicHigh))+3*j*PicWidth+3*i+2);
H=0;
break;
case 32:
if(STEPX*65536+STEPY+buchang+(h*PicXNum+w)*4*(PicWidth*PicHigh)+4*j*PicWidth+4*i>FileSize)
break;
R=*(unsigned char*)(FileBuf+buchang+STEPX*65536+STEPY+(h*PicXNum+w)*(8+4*(PicWidth*PicHigh))+4*j*PicWidth+4*i+1);
G=*(unsigned char*)(FileBuf+buchang+STEPX*65536+STEPY+(h*PicXNum+w)*(8+4*(PicWidth*PicHigh))+4*j*PicWidth+4*i+2);
B=*(unsigned char*)(FileBuf+buchang+STEPX*65536+STEPY+(h*PicXNum+w)*(8+4*(PicWidth*PicHigh))+4*j*PicWidth+4*i+3);
H=0;//*(unsigned char*)(FileBuf+buchang+STEPX*65536+STEPY+(h*PicXNum+w)*(8+4*(PicWidth*PicHigh))+4*j*PicWidth+4*i+3);
break;
case 22:
if(STEPX*65536+STEPY+buchang+(h*PicXNum+w)*4*(PicWidth*PicHigh)+4*j*PicWidth+4*i>FileSize)
break;
char tls,r,g,b;
r=*(int*)(FileBuf+buchang+STEPX*65536+STEPY+(h*PicXNum+w)*(8+4*(PicWidth*PicHigh))+4*j*PicWidth+4*i+0);
g=*(int*)(FileBuf+buchang+STEPX*65536+STEPY+(h*PicXNum+w)*(8+4*(PicWidth*PicHigh))+4*j*PicWidth+4*i+2);
b=*(int*)(FileBuf+buchang+STEPX*65536+STEPY+(h*PicXNum+w)*(8+4*(PicWidth*PicHigh))+4*j*PicWidth+4*i+3);
color=*(int*)(FileBuf+buchang+STEPX*65536+STEPY+(h*PicXNum+w)*(8+4*(PicWidth*PicHigh))+4*j*PicWidth+4*i);
tls=color&0x3;
color=(color>>14)|(tls);
R=(color>>12)*255/63;
G=((color>>6)&0x3f;)*255/63;
B=(color&0x3f;)*255/63;
/* R= ((r<<4)|((g&0xf0;)>>4))*255/63;
G= (((g&0x0f;)<<2)|((b&0xc0;)>>6))*255/63;
B= (b&0x3f;)*255/63;
*/
H=0;
break;
case 12:
if(STEPX*65536+STEPY+buchang+(h*PicXNum+w)*2*(PicWidth*PicHigh)+2*j*PicWidth+2*i>FileSize)
break;
gadd=FileBuf+buchang+STEPX*65536+STEPY+(h*PicXNum+w)*2*(PicWidth*PicHigh)+2*j*PicWidth+2*i;
RGB=*(unsigned short*)gadd;
color= ConverColor12t24(RGB);
if(x==w&&y==h&SelectPic;==1)
{
B=0xff-char((color&0x00ff0000;)>>16);
G=0xff-char((color&0x0000ff00;)>>8);
R=0xff-char(color&0x000000ff;);
H=0;
}
else
{
R=char((color&0x00ff0000;)>>16);
G=char((color&0x0000ff00;)>>8);
B=char(color&0x000000ff;);
H=0;
}
break;
}
p=(h*PicHigh+j)*(bm.bmWidth)+w*PicWidth+i;
Data[4*p]=B;
Data[4*p+1]=G;
Data[4*p+2]=R;
Data[4*p+3]=H;
}
Bitmap.SetBitmapBits(bm.bmHeight*bm.bmWidthBytes ,Data);
pDC->BitBlt(1,1,bm.bmWidth,bm.bmHeight,&MemDC;,0,0,SRCCOPY);
MemDC.SelectObject(pOldBitmap);
pDC->DeleteDC();
}
unsigned long CPhonePictureDlg::ConverColor16t24(short D)//瘻뻣16貫槨24貫꽈
{
int r,g,b;
unsigned long color;
if (D==0 || D==0xffff) return D;
r=D&0xf800;
r=r>>11;
r=r*255/31;
g=((D&0x7e0;)>>5)*255/63;
b=(D&0x1f;)*255/31;
color=b<<16|g<<8|r;
return color;
}
void CPhonePictureDlg::OnChangeSCROLLBARVertical()
{
// TODO: Add your control notification handler code here
int k;
switch(PICTYPE)
{
case 0:
k=1;
break;
case 1:
k=1;
break;
case 2:
k=1;
break;
case 3:
k=1;
break;
case 4:
k=1;
break;
case 5:
k=2;
break;
case 6:
k=3;
break;
case 7:
k=4;
break;
case 8:
k=2;
break;
case 9:
k=2;
}
STEPY=k*m_VERScrollBar.GetValue();
}
void CPhonePictureDlg::OnScrollSCROLLBARHorizontal()
{
// TODO: Add your control notification handler code here
STEPX=m_HORScrollBar.GetValue();
}
void CPhonePictureDlg::OnScrollSCROLLBARVertical()
{
// TODO: Add your control notification handler code here
int k;
switch(PICTYPE)
{
case 0:
k=1;
break;
case 1:
k=1;
break;
case 2:
k=1;
break;
case 3:
k=1;
break;
case 4:
k=1;
break;
case 5:
k=2;
break;
case 6:
k=3;
break;
case 7:
k=4;
break;
case 8:
k=2;
break;
case 9:
k=2;
}
STEPY=k*m_VERScrollBar.GetValue();
}
CString CPhonePictureDlg::Hex2Str(unsigned long add)
{
char s;
unsigned int i,h;
CString retdata;
retdata="0x";
if(add==0)
return "0x0";
int k;
for(i=0;i<8;i++)
{
h=add<<(i*4);
h=h>>28;
s=ConvertHex2Char(h);
if(s!=0x30||k==1 )
{
retdata+=s;
k=1;
}
}
return retdata;
}
char CPhonePictureDlg::ConvertHex2Char(int hex)
{
char retdata;
switch(hex)
{ case 0:
retdata='0';
break;
case 1:
retdata='1';
break;
case 2:
retdata='2';
break;
case 3:
retdata='3';
break;
case 4:
retdata='4';
break;
case 5:
retdata='5';
break;
case 6:
retdata='6';
break;
case 7:
retdata='7';
break;
case 8:
retdata='8';
break;
case 9:
retdata='9';
break;
case 10:
retdata='A';
break;
case 11:
retdata='B';
break;
case 12:
retdata='C';
break;
case 13:
retdata='D';
break;
case 14:
retdata='E';
break;
case 15:
retdata='F';
break;
}
return retdata;
}
void CPhonePictureDlg::OnSelchangeCombo1()
{
// TODO: Add your control notification handler code here
buchang=m_buchang.GetCurSel();
}
void CPhonePictureDlg::OnChangeAddress()
{
// TODO: If this is a RICHEDIT control, the control will not
// send this notification unless you override the CDialog::OnInitDialog()
// function and call CRichEditCtrl().SetEventMask()
// with the ENM_CHANGE flag ORed into the mask.
// TODO: Add your control notification handler code here
KillTimer(1);
CString data;
UpdateData(true);
data=m_address;
long address=Str2Hex(data);
STEPX=address/65536;
STEPY=(addresse536);
//m_VERScrollBar.SetValue(STEPY);
// OnScrollSCROLLBARVertical();
SetTimeOn(50);
}
unsigned long CPhonePictureDlg::Str2Hex(CString address)
{
unsigned long returndata;
int len,i,k,h;
len=address.GetLength();
CString s;
char d;
k=0;
returndata=0;
if(len>2)
{
s=address[0];
s+=address[1];
if(s=="0x"|s=="0X")
for(i=2;i='0')&&(ch<='9'))
return ch-0x30;
else if((ch>='A')&&(ch<='F'))
return ch-'A'+10;
else if((ch>='a')&&(ch<='f'))
return ch-'a'+10;
else return (-1);
}
void CPhonePictureDlg::PreSubclassWindow()
{
// TODO: Add your specialized code here and/or call the base class
CDialog::PreSubclassWindow();
}
void CPhonePictureDlg::ShowMoneColor(int k)
{
int i,j,p;
char RGB;
int w,h;
unsigned char R,G,B;
CBitmap Bitmap,*pOldBitmap;
BITMAP bm;
CDC MemDC;
CDC *pDC;
unsigned char Data[499200];
PicXNum=560/(8*PicWidth);
PicYNum=320/PicHigh;
pDC=m_image.GetDC();
Bitmap.LoadBitmap(IDB_BITMAP1);// Bitmap.CreateBitmap(560,320,1,24,NULL);//
//retrieve information about a CBitmap object
Bitmap.GetObject(sizeof(BITMAP),&bm;);
if(!MemDC.CreateCompatibleDC(pDC))
return ;
pOldBitmap=(CBitmap*)MemDC.SelectObject(&Bitmap;);
long picwidth=bm.bmWidth;
for(h=0;hFileSize)
return;
RGB=*(unsigned char*)(FileBuf+buchang+STEPX*65536+STEPY+(h*PicXNum+w)*(PicWidth*PicHigh)+PicWidth*j+i);
for(int m=0;m<8;m++)
{
R=RGB>>7-m;
R=R&0x1;
if(R )
{
B=0;
G=0;
R=0;
}
else
{
B=255;
G=255;
R=255;
}
p=(h*PicHigh+j)*(picwidth)+8*w*PicWidth+8*i+m;
Data[4*p]=B;
Data[4*p+1]=G;
Data[4*p+2]=R;
Data[4*p+3]=0;
}
}
Bitmap.SetBitmapBits(bm.bmHeight*bm.bmWidthBytes ,Data);
pDC->BitBlt(1,1,bm.bmWidth,bm.bmHeight,&MemDC;,0,0,SRCCOPY);
MemDC.SelectObject(pOldBitmap);
pDC->DeleteDC();
}
void CPhonePictureDlg::ShowMoneColorHH()
{
int i,j,p;
unsigned char RGB;
int w,h;
unsigned char R,G,B;
CBitmap Bitmap,*pOldBitmap;
BITMAP bm;
CDC MemDC;
CDC *pDC;
unsigned char Data[499200];
PicXNum=560/(PicWidth);
PicYNum=320/(8*PicHigh);
pDC=m_image.GetDC();
Bitmap.LoadBitmap(IDB_BITMAP1);// Bitmap.CreateBitmap(560,320,1,24,NULL);//
//retrieve information about a CBitmap object
Bitmap.GetObject(sizeof(BITMAP),&bm;);
if(!MemDC.CreateCompatibleDC(pDC))
return ;
pOldBitmap=(CBitmap*)MemDC.SelectObject(&Bitmap;);
long picwidth=bm.bmWidth;
for(h=0;hFileSize)
return;
RGB=*(unsigned char*)(FileBuf+buchang+STEPX*65536+STEPY+(h*PicXNum+w)*(PicWidth*PicHigh)+PicWidth*j+i);
for(int m=0;m<8;m++)
{
R=RGB>>7-m;
R=R&0x1;
if(R )
{
B=0;
G=0;
R=0;
}
else
{
B=255;
G=255;
R=255;
}
p=(h*PicHigh*8+j*8+7-m)*picwidth+w*PicWidth+i;
Data[4*p]=B;
Data[4*p+1]=G;
Data[4*p+2]=R;
Data[4*p+3]=0;
}
}
Bitmap.SetBitmapBits(bm.bmHeight*bm.bmWidthBytes ,Data);
pDC->BitBlt(1,1,bm.bmWidth,bm.bmHeight,&MemDC;,0,0,SRCCOPY);
MemDC.SelectObject(pOldBitmap);
pDC->DeleteDC();
}
void CPhonePictureDlg::ShowMoneColorH(int k)
{
int i,j,p;
char RGB;
int w,h;
unsigned char R,G,B;
CBitmap Bitmap,*pOldBitmap;
BITMAP bm;
CDC MemDC;
CDC *pDC;
unsigned char Data[499200];
PicXNum=560/(PicWidth);
PicYNum=320/(8*PicHigh);
pDC=m_image.GetDC();
Bitmap.LoadBitmap(IDB_BITMAP1);// Bitmap.CreateBitmap(560,320,1,24,NULL);//
//retrieve information about a CBitmap object
Bitmap.GetObject(sizeof(BITMAP),&bm;);
if(!MemDC.CreateCompatibleDC(pDC))
return ;
pOldBitmap=(CBitmap*)MemDC.SelectObject(&Bitmap;);
long picwidth=bm.bmWidth;
for(h=0;hFileSize)
return;
RGB=*(unsigned char*)(FileBuf+buchang+STEPX*65536+STEPY+(h*PicXNum+w)*(PicWidth*PicHigh)+PicHigh*j+i);
for(int m=0;m<8;m++)
{
R=RGB>>7-m;
R=R&0x1;
if(R )
{
B=0;
G=0;
R=0;
}
else
{
B=255;
G=255;
R=255;
}
p=(8*h*PicHigh+8*i+7-m)*(picwidth)+w*PicWidth+j;
Data[4*p]=B;
Data[4*p+1]=G;
Data[4*p+2]=R;
Data[4*p+3]=0;
}
}
Bitmap.SetBitmapBits(bm.bmHeight*bm.bmWidthBytes ,Data);
pDC->BitBlt(1,1,bm.bmWidth,bm.bmHeight,&MemDC;,0,0,SRCCOPY);
MemDC.SelectObject(pOldBitmap);
pDC->DeleteDC();
}
//DEL void CPhonePictureDlg::OnCustomdrawSlider1(NMHDR* pNMHDR, LRESULT* pResult)
//DEL {
//DEL // TODO: Add your control notification handler code here
//DEL PicWidth=m_slid.GetPos();
//DEL *pResult = 0;
//DEL }
void CPhonePictureDlg::OnChangeSCROLLBARHorizontal2()
{
// TODO: Add your control notification handler code here
PicWidth=m_width.GetValue()+1;
m_PicWidth=PicWidth;
UpdateData(false);
}
void CPhonePictureDlg::OnScrollSCROLLBARHorizontal2()
{
// TODO: Add your control notification handler code here
PicWidth=m_width.GetValue()+1;
m_PicWidth=PicWidth;
UpdateData(false);
}
void CPhonePictureDlg::OnChangeSCROLLBARHorizontal3()
{
// TODO: Add your control notification handler code here
PicHigh=m_high.GetValue()+1;
m_PicHigh=PicHigh;
UpdateData(false);
}
void CPhonePictureDlg::OnScrollSCROLLBARHorizontal3()
{
// TODO: Add your control notification handler code here
PicHigh=m_high.GetValue()+1;
m_PicHigh=PicHigh;
UpdateData(false);
}
void CPhonePictureDlg::OnDblClickImage1(LPDISPATCH Cancel)
{
SelectPic++;
if(SelectPic==2)
SelectPic=0;
}
void CPhonePictureDlg::OnPictureEditlayout()
{
int x,y,numx,numy;
char R,G,B;
char *temp;
numx=560/(PicWidth);
numy=320/PicHigh;
x=MousePoint.x/PicWidth;
y=MousePoint.y/PicHigh;
long Size;
unsigned long color,TLS;
unsigned short RGB;
int k;
switch(PICTYPE)
{
case 4:
k=1;
break;
case 5:
k=2;
break;
case 6:
k=3;
break;
case 7:
k=1;
break;
case 8:
k=18;
break;
case 9:
k=3;
break;
}
Size=PicWidth*PicHigh*k;
if(k!=1)
{
temp=(char*)malloc((PicWidth*3+4-PicWidth*3%4)*PicHigh+0x50);
*(long*)(BmpTitleBuf+0x12)=PicWidth;
*(long*)(BmpTitleBuf+0x16)=PicHigh;
memcpy(temp,BmpTitleBuf,54);
}
if(k==3)
{
memcpy(temp+54,FileBuf+STEPX*65536+STEPY+buchang+(y*numx+x)*Size,Size);
}
if(k==4)
{
memcpy(temp+54,FileBuf+STEPX*65536+STEPY+buchang+(y*numx+x)*Size,Size);
}
if(k==2)
{
Size=PicWidth*PicHigh;
for(int j=0;j>16);
G=char((color&0x0000ff00;)>>8);
R=char(color&0x000000ff;);
if(PicWidth*3%4!=0)
{
*(char*)(temp+54+(PicHigh-j-1)*(PicWidth*3+4-PicWidth*3%4)+i*3)=B;
*(char*)(temp+54+(PicHigh-j-1)*(PicWidth*3+4-PicWidth*3%4)+i*3+1)=G;
*(char*)(temp+54+(PicHigh-j-1)*(PicWidth*3+4-PicWidth*3%4)+i*3+2)=R;
}
else
{*(char*)(temp+54+(PicHigh-j-1)*(PicWidth*3 )+i*3)=B;
*(char*)(temp+54+(PicHigh-j-1)*(PicWidth*3 )+i*3+1)=G;
*(char*)(temp+54+(PicHigh-j-1)*(PicWidth*3 )+i*3+2)=R;
}
}
if(PicWidth*3%4!=0)
Size=(PicWidth*3+4-PicWidth*3%4)*PicHigh;
else
Size=(PicWidth*3)*PicHigh;
}
if(k==18)
{
Size=4*PicWidth*PicHigh;
for(int j=0;j>16);
G=char((color&0x0000ff00;)>>8);
R=char(color&0x000000ff;);
if(PicWidth*3%4!=0)
{
*(char*)(temp+54+(PicHigh-j-1)*(PicWidth*3+4-PicWidth*3%4)+i*3)=B;
*(char*)(temp+54+(PicHigh-j-1)*(PicWidth*3+4-PicWidth*3%4)+i*3+1)=G;
*(char*)(temp+54+(PicHigh-j-1)*(PicWidth*3+4-PicWidth*3%4)+i*3+2)=R;
}
else
{*(char*)(temp+54+(PicHigh-j-1)*(PicWidth*3 )+i*3)=B;
*(char*)(temp+54+(PicHigh-j-1)*(PicWidth*3 )+i*3+1)=G;
*(char*)(temp+54+(PicHigh-j-1)*(PicWidth*3 )+i*3+2)=R;
}
}
if(PicWidth*3%4!=0)
Size=(PicWidth*3+4-PicWidth*3%4)*PicHigh;
else
Size=(PicWidth*3)*PicHigh;
}
if(k==1)
{
if(PicWidth%4!=0)
Size=PicHigh*(PicWidth+4-PicWidth%4)+1078;
else
Size=PicHigh*(PicWidth)+1078;
temp=(char*)malloc(Size);
memcpy(temp,BmpTitleBuf+54,1078);
*(long*)(temp+0x12)=PicWidth;
*(long*)(temp+0x16)=PicHigh;
*(long*)(temp+2)=Size;
if(PicWidth%4!=0)
for(int j=0;j>8;
r=r*255/16;
g=((D&0xf0;)>>4)*255/16;
b=(D&0xf;)*255/16;
color=b<<16|g<<8|r;
return color;
}
unsigned long CPhonePictureDlg::ConverColor18t24(unsigned long color)
{
int r,g,b;
unsigned long D;
D=color&0x3ffff;
if (D==0)
return D;
if(D==0X3FFFF)
return 0xffffff;
r=D&0x3f000;
r=r>>12;
r=r*255/63;
g=((D&0xfc0;)>>6)*255/63;
b=(D&0x3f;)*255/63;
color=b<<16|g<<8|r;
return color;
}
unsigned long CPhonePictureDlg::ConverColor24t18(unsigned char R, unsigned char G, unsigned char B)
{
unsigned long color;
float x;
color=0;
R=R*63/255;
G=G*63/255;
B=B*63/255;
color=R<<12|G<<6|B;
return color;
}
void CPhonePictureDlg::OnBeforeDragOverImage1(LPDISPATCH Cancel, LPDISPATCH Data, float X, float Y, long DragState, LPDISPATCH Effect, short Shift)
{
// TODO: Add your control notification handler code here
}
void CPhonePictureDlg::OnBeforeDragOverSCROLLBARHorizontal2(LPDISPATCH Cancel, LPDISPATCH Data, float X, float Y, long DragState, LPDISPATCH Effect, short Shift)
{
// TODO: Add your control notification handler code here
}
【文件预览】:
PhonePicture.exe