|
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.
|
|
|
|
|
Thank you very much. But If I have some problems, I will ask you again (~_*)
Ngo Khai Hoa
|
|
|
|
|
By all means
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.
|
|
|
|
|
I have a simple dialog based application that employs a RichEditCtrl (Microsoft Rich Text box control 6.0 (SP4)).
I have included AfxInitRichEdit() when the application is initialised.
On the system that the program was developed it works fine in both debug and release version.
When it is installed on another PC the program fails to display.
Both systems are configured with the same operating system NT 4 (SP5).
Can any one help me.
Note:
1. I have verified that the files listed in the Depends tracker are the same on both systems. Ensuring that the files listed were the same on both machines did not resolve the problem.
2. If I install Visual C++ V6 along with SP5.0 and then uninstall Visual C++, the program works fine. This is the only difference between the development platform and the target platform.
3. The sample program WordPad works fine without needing to install visual C++ on the target pc. Does this infer that the CRichEditView class should be associated with the RichEdit control in some way if so how do I associate it with the instance of the Edit control on the dialog.
Thanks in Advance...
|
|
|
|
|
hi,,
I like to know how can i serialize bitmaps..
I'm using the following codes, but it doesn't work.
void CEdgeDoc::Serialize(CArchive& ar)
{
if (ar.IsStoring())
{
// TODO: add storing code here
m_bmpBitMap.Serialize(ar);
}
else
{
// TODO: add loaing code here
m_bmpBitMap.Serialize(ar);
}
}
I don;t have a bitmap class, m_bmpBitMap is a CBitmap object.
1-should I have a Bitmap class?
can someone giude me please.
Thanks
Ehsan Behboudi
|
|
|
|
|
How else to easily share code between projects? Right now I have MSVC create project subfolders of the c:\devel directory and I have a bunch of .cpp and .h files for common functions in a c:\classes directory. Whenever I need a frequently used class I just 'add files to project' from c:\classes and then #include "c:\classes\foo.h".
I've never worked on projects with other people before, but I can see that I should find another way to do it in case I have the opportunity to collaborate in the future.
|
|
|
|
|
Always use #include with relative path for example #include "..\classes\foo.h" , in this way you will be able to move the project with out any problems.
|
|
|
|
|
First, it's a good idea for everyone to have the same directory structure (if for no other reason that to serve as a common frame of reference). For instance, I have the following directory structure for ne of my projects:
\Johns Projects\ --- CommonFiles
--- DeMONS2\ --- D2CommonFiles
--- D2Config
--- D2Launcher
--- D2Scrub
With the directory structure described above, any project in the johns projects root can get to any header file in CommonFiles or D2CommonFiles, even if "Johns Projects" has another name or is copied (in its entirety) to another drive altogether
In your project settings dialog...
1) Click Project | Settings... in the Visual Studio menu.
2) On the left side of the dialog, you'll see a combo box labeled "Settings for:". Select "All Configurations".
3) On the right side of the dialog, select the "C++" tab, and in the combo box labeled "Category:", click the "Preprocessor" item (last one in the list).
4) In the edit field lebaleled "Additional Include Directories:", and your relative path. Using the directory structure example above, for all of the projects in the DeMONS2 folder (D2Launcher, D2Config, and D2Scrub), I used "..\..\CommonFiles,..\D2CommonFiles".
At this point, all you have to do is #include the filename itself without worrying about the path at all.
In order to share a project, everyone will find it much simpler to just have identical directory structures.
|
|
|
|
|
Hi,
I have a graphical MDI application, it displays Bitmaps, draws points, lines,...
All the data is in my CView class.
Can I use serialization from CView? if yes.. How??
thanks
Ehsan Behboudi
|
|
|
|
|
I've been trying to do this for longer than I care to admit and every implimentation I try reactivates the last window that was active, even if my mouse is a long way away from it, over another view entirely.
Please help, or alternatively please send me a nice long piece of rope, and instructions on how to tie a noose.
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.
|
|
|
|
|
Try this:
1) Create a base view class that all ytour other views derive from.
2) Create a member variable of type CRect (we'll call it m_windowRect)
2) Override OnSize()
3) In the OnSize() function, insert the following code:
GetWindowRect(&m_windowRect);
ClientToScreen(&m_windowRect);
4) Override the OnMouseMove() function
5) In the OnMouseMove() function, insert the following code:
if (GetFocus() != this)
{
ClientToScreen(&point);
if (m_windowRect.PtInRect(point)
{
SetFocus();
}
}
I havn't tried any of this myself, but it should work with minimal tweaking.
|
|
|
|
|
Thanks, but I've tried it and apart from keeping the rect as a member variable, it's pretty much where I started out, and the same problem is evident - the last view highlighted activates instead of the one the mouse is over. I've gone so far as to iterate through all my views and grab their positions, but no matter what I do, the last view highlighted gets activated...
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.
|
|
|
|
|
Have you tried using WindowFromPoint() ?
Neville Franks, Author of ED for Windows
http://www.getsoft.com
|
|
|
|
|
I love you, and I want to bear your children.....
I spent half a day searching the MSDN for this API function - thanks, I'll give it a try.
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.
|
|
|
|
|
OK.. I am drawing a graph in my view and then want to save the point array in my document. Problem arises when i serialise.. During run, when I try to save it, he save window comes up fine.. but the graph is erased when my view is redrawn after closing the save dialog box. I did put invalidateRect in my OnDraw function .. but didn't work!!
I also added a call to UpdateAllWindows in the overriden Serialize function for my CDocument.. but still does not work!!!
also, anyone knows how to obtain a pointer to the current view from CDocument??
It is what we choose to be that makes us what we are, far more than our abilities.
-J.K. Rowling
|
|
|
|
|
To get a pointer to the View from your document:
CFrameWnd *pFrameWnd = (CFrameWnd *)AfxGetMainWnd();
ASSERT (pFrameWnd != NULL && pFrameWnd->IsKindOf(RUNTIME_CLASS(CMDIFrameWnd)));
pFrameWnd = ((CMDIFrameWnd *)pFrameWnd)->GetActiveFrame();
CMyView * pView = (CMyView*)pFrameWnd->GetActiveView();
This is a generic method - it works from anywhere, but only works if your document is attached to the active view.
Your other problem is a mystery to me. Could you post some code to show what you're doing ?
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.
|
|
|
|
|
How can I in get MX Records from DNS when I know only hostname or ip of main server?
Please Reply to my email:piopawlu@interia.pl
Piotr Pawluczuk
|
|
|
|
|
Does anyone know how to use DeviceIoControl()??? I read the document from microsoft and MSDN...but still don't know how to use it.....can anyone give me a small tutorial about this function?
Thanks
|
|
|
|
|
Hi All,
I'm beginner in VC++ and I have VC++ 6.0. I have this problem now.
How I create user items in system menu of my applications ?
Thanks,
Libor
Libor Matejka
|
|
|
|
|
Please explain ? If you want to add items to the menus, use the resource editor to create items and then Class Wizard to create functions linked to the item ID's. If that is not what you mean, please re-state the question.
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.
|
|
|
|
|
Thank you for your answer, but I mean SYSTEM menu. This is menu under Application icon in caption bar of application.
Libor Matejka
|
|
|
|
|
Create a sample Dialog based application, then look at the implementation of the OnInitDialog member function. In here you will see how the About Box menu option is added to the System Menu. From this you should be able to add almost anything you like to the System Menu.
Michael Martin
Pegasystems Pty Ltd
Australia
martm@pegasystems.com
+61 413-004-018
|
|
|
|
|
Thank you,
this is very simle and fast
Libor Matejka
|
|
|
|
|
I send when I click on a static text (CLabel) a message to my main app that I intercept with the OnNotify() routine.
(I don't have the listing right now this explain the aproximate syntax sorry bout this)
But I noticed annoying long delay (1 second) before I can re click on the static
should I return 0; once I get the message ?
For now I alway return to the normal OnNotify procedure
Onnotify( wparam, lparam ...)
{
switch(proc)
{
case:
some code;
return 0; <---For now I just have a "BREAK;" here
}
return Onnotify();
}
Many thanks
|
|
|
|
|
I have declared a function called solve like this :
double Solve(double (pFn) (double), double pX);
Now I don't know how to use this function with for example pFn = 2*X-1...
the following code doesn't work :
lSoluce = Solve( (2*X-1) (X), X) ????
Thank in advance for your help.
Leo
|
|
|
|