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

C / C++ / MFC

 
GeneralNIIF_NONE Pin
BlackDice18-Aug-04 5:30
BlackDice18-Aug-04 5:30 
General#if (_WIN32_IE >= 0x0500) Pin
BlackDice18-Aug-04 5:45
BlackDice18-Aug-04 5:45 
GeneralRe: #if (_WIN32_IE >= 0x0500) Pin
Steve Thresher18-Aug-04 5:52
Steve Thresher18-Aug-04 5:52 
GeneralRe: NIIF_NONE Pin
Steve Thresher18-Aug-04 5:48
Steve Thresher18-Aug-04 5:48 
GeneralRe: NIIF_NONE Pin
BlackDice18-Aug-04 5:56
BlackDice18-Aug-04 5:56 
GeneralRe: NIIF_NONE Pin
BlackDice18-Aug-04 6:07
BlackDice18-Aug-04 6:07 
GeneralRe: NIIF_NONE Pin
Michael Dunn18-Aug-04 7:17
sitebuilderMichael Dunn18-Aug-04 7:17 
QuestionWhat wrong with this code? Pin
gilazilla18-Aug-04 4:51
gilazilla18-Aug-04 4:51 
Hi,
i tried to modify the codes to display only gray scale image and aslo the original image.So far my program just display a blank bitmap.Anyone can please help me.

void CMy2ndtryView::OnDraw(CDC* pDC)
{
CMy2ndtryDoc* pDoc = GetDocument();
ASSERT_VALID(pDoc);
// TODO: add draw code for native data here


CDC MemDC;
MemDC.CreateCompatibleDC (NULL);
MemDC.SelectObject (&m_Bitmap);

pDC->BitBlt
(20,
20,
m_BitmapWidth,
m_BitmapHeight,
&MemDC,
0,
0,
SRCCOPY);


CDC resultDC;
CBitmap m_result;

m_result.CreateCompatibleBitmap(pDC,m_BitmapWidth,m_BitmapHeight);
resultDC.CreateCompatibleDC (NULL);
resultDC.SelectObject (&m_Bitmap);

for( int y = 0; y < m_BitmapHeight ; y++ )
{
for( int x = 0; x < m_BitmapWidth ; x++ )
{
//set pixel to color returned by convolve
resultDC.SetPixel(x,y,Convolve(&MemDC,x,y,kernel));
}
}


//Display Result
pDC->BitBlt
(300,
20,
m_BitmapWidth,
m_BitmapHeight,
&resultDC,
0,
0,
SRCCOPY);



}

COLORREF CMy2ndtryView::Convolve(CDC *pDC, int sourcex, int sourcey, float kernel[][3])
{
float rSum = 0, gSum = 0, bSum = 0, kSum = 0;
float grayscale =0;
COLORREF clrReturn = RGB(0,0,0);
for (int i=0; i <= 2; i++)//loop through rows
{
for (int j=0; j <= 2; j++)//loop through columns
{


COLORREF tmpPixel = pDC->GetPixel(sourcex+(i-(2>>1)),sourcey+(j-(2>>1)));

float fKernel = kernel[i][j];

rSum += (GetRValue(tmpPixel)*fKernel);
gSum += (GetGValue(tmpPixel)*fKernel);
bSum += (GetBValue(tmpPixel)*fKernel);

kSum += fKernel;
}
}

if (kSum <= 0)
kSum = 1;

rSum/=kSum;
gSum/=kSum;
bSum/=kSum;
if (rSum > 255)
rSum = 255;
else if (rSum < 0)
rSum = 0;
if (gSum > 255)
gSum = 255;
else if (gSum < 0)
gSum = 0;
if (bSum > 255)
bSum = 255;
else if (bSum < 0)
bSum = 0;

grayscale=0.299*rSum + 0.587*gSum + 0.114*bSum;
rSum=grayscale;
gSum=grayscale;
bSum=grayscale;

clrReturn = RGB(rSum,gSum,bSum);
return clrReturn;


}

Is there something with my formula for grayscale?
grayscale=0.299*rSum + 0.587*gSum + 0.114*bSum;
GeneralDrag and Drop Using the CFSTR_FILEDESCRIPTOR / CFSTR_FILECONTENTS Formats Pin
Steve Thresher18-Aug-04 4:48
Steve Thresher18-Aug-04 4:48 
Generalnew in dll, delete in exe, bang :( Pin
Rüpel18-Aug-04 3:42
Rüpel18-Aug-04 3:42 
GeneralRe: new in dll, delete in exe, bang :( Pin
Nemanja Trifunovic18-Aug-04 3:58
Nemanja Trifunovic18-Aug-04 3:58 
GeneralRe: new in dll, delete in exe, bang :( Pin
Rüpel18-Aug-04 4:22
Rüpel18-Aug-04 4:22 
GeneralRe: new in dll, delete in exe, bang :( Pin
Ravi Bhavnani18-Aug-04 4:13
professionalRavi Bhavnani18-Aug-04 4:13 
Generalbitmap file format Pin
peterworth18-Aug-04 3:21
peterworth18-Aug-04 3:21 
GeneralRe: bitmap file format Pin
Chris Losinger18-Aug-04 4:27
professionalChris Losinger18-Aug-04 4:27 
GeneralRe: bitmap file format Pin
Anonymous18-Aug-04 4:46
Anonymous18-Aug-04 4:46 
GeneralRe: bitmap file format Pin
Chris Losinger18-Aug-04 4:54
professionalChris Losinger18-Aug-04 4:54 
GeneralRe: bitmap file format Pin
Anonymous18-Aug-04 4:57
Anonymous18-Aug-04 4:57 
GeneralRe: bitmap file format Pin
Chris Losinger18-Aug-04 5:03
professionalChris Losinger18-Aug-04 5:03 
GeneralRe: bitmap file format Pin
Anonymous18-Aug-04 5:08
Anonymous18-Aug-04 5:08 
GeneralRe: bitmap file format Pin
Chris Losinger18-Aug-04 5:14
professionalChris Losinger18-Aug-04 5:14 
GeneralRe: bitmap file format Pin
Rick York18-Aug-04 10:22
mveRick York18-Aug-04 10:22 
GeneralHELP NEEDED, With Windows Default Settings. Pin
Yaxcidia18-Aug-04 2:52
Yaxcidia18-Aug-04 2:52 
GeneralRe: HELP NEEDED, With Windows Default Settings. Pin
David Crow18-Aug-04 6:19
David Crow18-Aug-04 6:19 
GeneralRe: HELP NEEDED, With Windows Default Settings. Pin
Yaxcidia18-Aug-04 8:19
Yaxcidia18-Aug-04 8:19 

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.