Click here to Skip to main content
16,005,141 members
Home / Discussions / C / C++ / MFC
   

C / C++ / MFC

 
Questionsave options using registry or file? Pin
Mohammad Tarik16-Feb-05 8:17
Mohammad Tarik16-Feb-05 8:17 
AnswerRe: save options using registry or file? Pin
rocky_pulley16-Feb-05 8:26
rocky_pulley16-Feb-05 8:26 
AnswerRe: save options using registry or file? Pin
Ravi Bhavnani16-Feb-05 9:23
professionalRavi Bhavnani16-Feb-05 9:23 
AnswerRe: save options using registry or file? Pin
Mohammad Tarik16-Feb-05 9:49
Mohammad Tarik16-Feb-05 9:49 
AnswerRe: save options using registry or file? Pin
ThatsAlok16-Feb-05 18:00
ThatsAlok16-Feb-05 18:00 
GeneralBinary serial communications Pin
ed7115516-Feb-05 8:09
ed7115516-Feb-05 8:09 
GeneralRe: Binary serial communications Pin
Ravi Bhavnani16-Feb-05 8:15
professionalRavi Bhavnani16-Feb-05 8:15 
GeneralINTERNAL COMPILER ERROR Pin
kalaichris16-Feb-05 7:35
kalaichris16-Feb-05 7:35 
these are my codes for image processing...im not sure why im getting this " INTERNAL COMPILER ERROR". pls help me...and pls do tell me whether if i continue with this codes, will i be able to perform thinning and edge detection..i have problems in developing the codes..pls do help me and i sincerely appreciate all the helps..thank you...

#include "stdafx.h"
#include "fvas.h"
#include "fvasDlg.h"
#include <math.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()

/////////////////////////////////////////////////////////////////////////////
// CFvasDlg dialog

CFvasDlg::CFvasDlg(CWnd* pParent /*=NULL*/)
: CDialog(CFvasDlg::IDD, pParent)
{
//{{AFX_DATA_INIT(CFvasDlg)
// NOTE: the ClassWizard will add member initialization here
//}}AFX_DATA_INIT
// Note that LoadIcon does not require a subsequent DestroyIcon in Win32
m_hIcon = AfxGetApp()->LoadIcon(IDR_MAINFRAME);
}

void CFvasDlg::DoDataExchange(CDataExchange* pDX)
{
CDialog::DoDataExchange(pDX);
//{{AFX_DATA_MAP(CFvasDlg)
// NOTE: the ClassWizard will add DDX and DDV calls here
//}}AFX_DATA_MAP
}

BEGIN_MESSAGE_MAP(CFvasDlg, CDialog)
//{{AFX_MSG_MAP(CFvasDlg)
ON_WM_SYSCOMMAND()
ON_WM_PAINT()
ON_WM_QUERYDRAGICON()
ON_BN_CLICKED(IDC_BUTTON1_DISPLAY, OnDisplay)
ON_BN_CLICKED(IDC_STATIC_BITMAP, OnStaticBitmap)
//}}AFX_MSG_MAP
END_MESSAGE_MAP()

/////////////////////////////////////////////////////////////////////////////
// CFvasDlg message handlers

BOOL CFvasDlg::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

// TODO: Add extra initialization here

return TRUE; // return TRUE unless you set the focus to a control
}

void CFvasDlg::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 CFvasDlg::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(&rect);
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 CFvasDlg::OnQueryDragIcon()
{
return (HCURSOR) m_hIcon;
}

void CFvasDlg::OnDisplay()
{
// TODO: Add your control notification handler code here
static char BASED_CODE szFilter[] = "Bitmap Files (*.bmp) |*.bmp||";

CString m_sBitmap;
CFileDialog m_ldFile(TRUE, ".bmp", m_sBitmap, OFN_HIDEREADONLY | OFN_OVERWRITEPROMPT, szFilter);

if (m_ldFile.DoModal() == IDOK)
{
m_sBitmap = m_ldFile.GetPathName();

HBITMAP hBitmap = (HBITMAP) ::LoadImage(AfxGetInstanceHandle(), m_sBitmap, IMAGE_BITMAP, 100,140, LR_LOADFROMFILE | LR_CREATEDIBSECTION);

HBITMAP hGrayBitmap = (HBITMAP) ::LoadImage(AfxGetInstanceHandle(), m_sBitmap, IMAGE_BITMAP, 100,140, LR_LOADFROMFILE | LR_CREATEDIBSECTION);

HBITMAP hGrayBitmap1 = (HBITMAP) ::LoadImage(AfxGetInstanceHandle(), m_sBitmap, IMAGE_BITMAP, 100,140, LR_LOADFROMFILE | LR_CREATEDIBSECTION);

BITMAP bm;
BITMAP bm1;

GetObject(hGrayBitmap, sizeof(BITMAP), (LPSTR)&bm);

typedef struct tagBITMAP
{
LONG bmType;
LONG bmWidth;
LONG bmHeight;
LONG bmWidthBytes;
WORD bmPlanes;
WORD bmBitsPixel;
LPVOID bmBits;
}
BITMAP, *PBITMAP;

if (hGrayBitmap)
{
CStatic *pImgPicture = (CStatic*)GetDlgItem(IDC_STATIC_BITMAP);
BYTE * pImgByte = (BYTE *) bm.bmBits;


if(pImgPicture==NULL)
{
AfxMessageBox("Fail to get Picture Control");
}
else
{

INT iWidthBytes = bm.bmWidth * 3;

for ( int y = 0; y < bm.bmHeight; y++)
{
for ( int x = 0; x < bm.bmWidth*3; x++)
{

unsigned char R = pImgByte[y*iWidthBytes+x+2];
unsigned char G = pImgByte[y*iWidthBytes+x+1];
unsigned char B = pImgByte[y*iWidthBytes+x];;

INT gray = ceil(0.3*R + 0.59*G + 0.11*B);

pImgByte[y*iWidthBytes+x+2] = gray;
pImgByte[y*iWidthBytes+x+1] = gray;
pImgByte[y*iWidthBytes+x] = gray;
}

}

void threshold (struct Image *bm, struct Image *bm1, int THRES)
{
int X, Y, GO, GB;
GO= 225;
GB= 0;

for (Y=0; Y<=bm.bmHeight; Y++)
{
for (X=0; X<=bm.bmWidth*3; X++)
{
if (*(bm.bmBitsPixel + X + (long) Y * bm.bmWidth*3) > THRES)
*(bm1.bmBitsPixel + X + (long) Y * bm.bmWidth*3) = GO;
else
*(bm1.bmBitsPixel + X + (long) Y * bm.bmWidth*3) = GB;
}
}
}

pImgPicture->SetBitmap(hGrayBitmap);
}

}
}


}
GeneralRe: INTERNAL COMPILER ERROR Pin
David Crow16-Feb-05 7:43
David Crow16-Feb-05 7:43 
GeneralRe: INTERNAL COMPILER ERROR Pin
Bob Ciora16-Feb-05 10:34
Bob Ciora16-Feb-05 10:34 
GeneralRe: INTERNAL COMPILER ERROR Pin
Bob Ciora16-Feb-05 10:41
Bob Ciora16-Feb-05 10:41 
GeneralRe: INTERNAL COMPILER ERROR Pin
David Crow16-Feb-05 10:51
David Crow16-Feb-05 10:51 
GeneralRe: INTERNAL COMPILER ERROR Pin
Bob Ciora16-Feb-05 14:05
Bob Ciora16-Feb-05 14:05 
GeneralRe: INTERNAL COMPILER ERROR Pin
David Crow16-Feb-05 16:35
David Crow16-Feb-05 16:35 
GeneralRe: INTERNAL COMPILER ERROR Pin
Ryan Binns16-Feb-05 17:49
Ryan Binns16-Feb-05 17:49 
GeneralChecking if a folder exists... Pin
ChemmieBro16-Feb-05 7:30
ChemmieBro16-Feb-05 7:30 
GeneralRe: Checking if a folder exists... Pin
David Crow16-Feb-05 7:41
David Crow16-Feb-05 7:41 
GeneralRe: Checking if a folder exists... Pin
ChemmieBro16-Feb-05 9:06
ChemmieBro16-Feb-05 9:06 
GeneralRe: Checking if a folder exists... Pin
David Crow17-Feb-05 3:33
David Crow17-Feb-05 3:33 
GeneralRe: Checking if a folder exists... Pin
ChemmieBro17-Feb-05 3:35
ChemmieBro17-Feb-05 3:35 
GeneralRe: Checking if a folder exists... Pin
David Crow17-Feb-05 3:55
David Crow17-Feb-05 3:55 
GeneralRe: Checking if a folder exists... Pin
Blake Miller17-Feb-05 7:59
Blake Miller17-Feb-05 7:59 
GeneralRe: Checking if a folder exists... Pin
Ryan Binns16-Feb-05 17:52
Ryan Binns16-Feb-05 17:52 
GeneralRe: Checking if a folder exists... Pin
digwizfox17-Feb-05 6:47
digwizfox17-Feb-05 6:47 
GeneralClient / Server Pin
densitet16-Feb-05 6:17
densitet16-Feb-05 6:17 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.