Click here to Skip to main content
15,893,486 members
Home / Discussions / C / C++ / MFC
   

C / C++ / MFC

 
Generalcreating controls on the desktop?!! Pin
28-Jun-01 20:03
suss28-Jun-01 20:03 
GeneralRe: creating controls on the desktop?!! Pin
Drake Elsari29-Jun-01 4:40
Drake Elsari29-Jun-01 4:40 
GeneralImage Operations Pin
Tran Hoang Chuong28-Jun-01 18:43
Tran Hoang Chuong28-Jun-01 18:43 
GeneralRe: Image Operations Pin
Christian Graus28-Jun-01 19:03
protectorChristian Graus28-Jun-01 19:03 
GeneralRe: Image Operations Pin
Tran Hoang Chuong28-Jun-01 19:37
Tran Hoang Chuong28-Jun-01 19:37 
GeneralRe: Image Operations Pin
Christian Graus28-Jun-01 19:42
protectorChristian Graus28-Jun-01 19:42 
GeneralRe: Image Operations Pin
Tran Hoang Chuong28-Jun-01 19:47
Tran Hoang Chuong28-Jun-01 19:47 
GeneralRe: Image Operations Pin
Christian Graus28-Jun-01 19:56
protectorChristian Graus28-Jun-01 19:56 
If you're stepping through a 24 bit image, then it's like this

unsigned char * pPixel = pMyArray;

for (int y = 0; y < m_Height; y++)
    for (int x = 0; x < m_Width; x++)
   {
        pPixel[0] += m_Brightness;
        pPixel[1] += m_Brightness;
        pPixel[2] += m_Brightness;

        pPixel += 3;
   }


Basically unsigned char runs from 0-255, so you don't need bounds checking. We step through all the bits and add the brightness value, which can be negative. The only thing that is worth mentioning, although it doesn't matter in this case, is that Windows bitmaps are stored as BGR, not RGB.



Here is a contrast filter:

register double red, green, blue;
register double csupp = contrast * (m_offset - 125.0) + 125.0;

for (int y = 0; y < pBmpDest->GetHeight(); ++y)
{ // For each line
register BYTE * pSrcPixel = pSrcLines[y];
register BYTE * pDstPixel = pDstLines[y];

for (register int x = 0; x < destWidth; ++x)
{
// Formel für Kontrastberechnung:
// v = (contrast * (v - 125.0 + m_offset) + 125.0);
red = contrast * ((double) (pSrcPixel[RGBA_RED])) + csupp;
green = contrast * ((double) (pSrcPixel[RGBA_GREEN])) + csupp;
blue = contrast * ((double) (pSrcPixel[RGBA_BLUE])) + csupp;

if(red >= 255.0)
pDstPixel[RGBA_RED] = (BYTE) 255;
else if (red < 0.0)
pDstPixel[RGBA_RED] = (BYTE) 0;
else
pDstPixel[RGBA_RED] = (BYTE) red;

if(green >= 255.0)
pDstPixel[RGBA_GREEN] = (BYTE) 255;
else if (green < 0.0)
pDstPixel[RGBA_GREEN] = (BYTE) 0;
else
pDstPixel[RGBA_GREEN] = (BYTE) green;

if(blue >= 255.0)
pDstPixel[RGBA_BLUE] = (BYTE) 255;
else if (blue < 0.0)
pDstPixel[RGBA_BLUE] = (BYTE) 0;
else
pDstPixel[RGBA_BLUE] = (BYTE) blue;

pSrcPixel += inc;
pDstPixel += inc;
}
}

All the bounds checking is superfluous as I mentioned before. I got this from paintlib, which is available from www.paintlib.de, and has a lot of filter code in it. I'd be happy to send you other filters I have written, including smooth, sharpen, emboss, etc.

Christian

#include "std_disclaimer.h"

People who love sausage and respect the law should never watch either one being made.

The things that come to those who wait are usually the things left by those who got there first.
GeneralRe: Image Operations Pin
Tran Hoang Chuong28-Jun-01 20:07
Tran Hoang Chuong28-Jun-01 20:07 
GeneralRe: Image Operations Pin
Christian Graus28-Jun-01 20:08
protectorChristian Graus28-Jun-01 20:08 
GeneralRich Text Pin
Steven Armstrong28-Jun-01 16:52
Steven Armstrong28-Jun-01 16:52 
GeneralSerializing Bitmaps Pin
mr200328-Jun-01 16:16
mr200328-Jun-01 16:16 
GeneralHard coded path names Pin
Alex Griffing28-Jun-01 15:56
Alex Griffing28-Jun-01 15:56 
GeneralRe: Hard coded path names Pin
28-Jun-01 18:08
suss28-Jun-01 18:08 
GeneralRe: Hard coded path names Pin
#realJSOP29-Jun-01 3:52
mve#realJSOP29-Jun-01 3:52 
QuestionHow do I implement serialization from my Cview class Pin
mr200328-Jun-01 14:45
mr200328-Jun-01 14:45 
QuestionHow do I activate the view my mouse goes over in an MDI app ? Pin
Christian Graus28-Jun-01 14:26
protectorChristian Graus28-Jun-01 14:26 
AnswerRe: How do I activate the view my mouse goes over in an MDI app ? Pin
#realJSOP29-Jun-01 4:09
mve#realJSOP29-Jun-01 4:09 
GeneralRe: How do I activate the view my mouse goes over in an MDI app ? Pin
Christian Graus29-Jun-01 21:04
protectorChristian Graus29-Jun-01 21:04 
GeneralRe: How do I activate the view my mouse goes over in an MDI app ? Pin
Neville Franks29-Jun-01 22:06
Neville Franks29-Jun-01 22:06 
GeneralRe: How do I activate the view my mouse goes over in an MDI app ? Pin
Christian Graus30-Jun-01 0:32
protectorChristian Graus30-Jun-01 0:32 
QuestionHow do I stop my view from being erased after serialising the document??? Pin
Ananya Sen Gupta28-Jun-01 11:50
Ananya Sen Gupta28-Jun-01 11:50 
AnswerRe: How do I stop my view from being erased after serialising the document??? Pin
Christian Graus28-Jun-01 14:12
protectorChristian Graus28-Jun-01 14:12 
GeneralMX Records and DNS Pin
28-Jun-01 10:55
suss28-Jun-01 10:55 
GeneralDeviceIoControl() question Pin
28-Jun-01 10:34
suss28-Jun-01 10:34 

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.