Sign in to follow this  
mostaqil cts

Plz plzi need help

Recommended Posts

mostaqil cts    122
i have this code for c++: typedef unsigned_int32 ULONG_PTR; //#define ULONG_PTR ULONG#define UNICODE #include <windows.h> #include <Gdiplus.h> using namespace Gdiplus; #pragma comment(lib, "gdiplus.lib") #include <math.h> #include <stdio.h> using namespace Gdiplus; VOID OnPaint(HDC hdc) { Graphics graphics(hdc); Bitmap b(L"Calvin.jpg"); Bitmap* b2; INT iWidth = b.GetWidth(); INT iHeight = b.GetHeight(); Rect rect(0,0,iWidth,iHeight); b2 = b.Clone(rect,PixelFormat24bppRGB); BitmapData bmData; BitmapData bmData2; b.LockBits(&rect,ImageLockModeRead | ImageLockModeWrite,PixelFormat24bppRGB,&bmData); b2->LockBits(&rect,ImageLockModeRead |ImageLockModeWrite,PixelFormat24bppRGB,&bmData2); int stride = bmData.Stride; unsigned char * p = (unsigned char *)bmData.Scan0; unsigned char * p2 = (unsigned char *)bmData2.Scan0; int nOffset = stride - iWidth*3; int nWidth = iWidth * 3; int nPixel = 0, nPixelMax = 0; p += stride; p2 += stride; int nThreshold = 0; for(int y=1;y<iHeight-1;++y) { p += 3; p2 += 3; for(int x=3; x < nWidth-3; ++x ) { nPixelMax = abs((p2 - stride + 3)[0] - (p2+stride-3)[0]); nPixel = abs((p2 + stride + 3)[0] - (p2 - stride - 3)[0]); if (nPixel>nPixelMax) nPixelMax = nPixel; nPixel = abs((p2 - stride)[0] - (p2 + stride)[0]); if (nPixel>nPixelMax) nPixelMax = nPixel; nPixel = abs((p2+3)[0] - (p2 - 3)[0]); if (nPixel>nPixelMax) nPixelMax = nPixel; if (nPixelMax < nThreshold) nPixelMax = 0; /*if(nPixelMax > nThreshold && nPixelMax < 35) nPixelMax = 0; if(nPixelMax > 35) nPixelMax = 255;*/ p[0] = (byte) nPixelMax; ++ p; ++ p2; } p += 3 + nOffset; p2 += 3 + nOffset; } b.UnlockBits(&bmData); b2->UnlockBits(&bmData2); graphics.DrawImage(b2,0,0,iWidth,iHeight); graphics.DrawImage(&b, iWidth+10, 0, iWidth, iHeight); } LRESULT CALLBACK WndProc(HWND, UINT, WPARAM, LPARAM); INT WINAPI WinMain(HINSTANCE hInstance, HINSTANCE, PSTR, INT iCmdShow) { HWND hWnd; MSG msg; WNDCLASS wndClass; GdiplusStartupInput gdiplusStartupInput; ULONG_PTR gdiplusToken; // Initialize GDI+. GdiplusStartup(&gdiplusToken, &gdiplusStartupInput, NULL); wndClass.style = CS_HREDRAW | CS_VREDRAW; wndClass.lpfnWndProc = WndProc; wndClass.cbClsExtra = 0; wndClass.cbWndExtra = 0; wndClass.hInstance = hInstance; wndClass.hIcon = LoadIcon(NULL, IDI_APPLICATION); wndClass.hCursor = LoadCursor(NULL, IDC_ARROW); wndClass.hbrBackground = (HBRUSH)GetStockObject(WHITE_BRUSH); wndClass.lpszMenuName = NULL; wndClass.lpszClassName = TEXT("Edge Detection"); RegisterClass(&wndClass); hWnd = CreateWindow( TEXT("Edge Detection"), // window class name TEXT("Edge Detection"), // window caption WS_OVERLAPPEDWINDOW, // window style CW_USEDEFAULT, // initial x position CW_USEDEFAULT, // initial y position CW_USEDEFAULT, // initial x size CW_USEDEFAULT, // initial y size NULL, // parent window handle NULL, // window menu handle hInstance, // program instance handle NULL); // creation parameters ShowWindow(hWnd, iCmdShow); UpdateWindow(hWnd); while(GetMessage(&msg, NULL, 0, 0)) { TranslateMessage(&msg); DispatchMessage(&msg); } GdiplusShutdown(gdiplusToken); return msg.wParam; } // WinMain LRESULT CALLBACK WndProc(HWND hWnd, UINT message, WPARAM wParam, LPARAM lParam) { HDC hdc; PAINTSTRUCT ps; switch(message) { case WM_CREATE: //OnCreate(); return 0; case WM_PAINT: hdc = BeginPaint(hWnd, &ps); OnPaint(hdc); EndPaint(hWnd, &ps); return 0; case WM_DESTROY: PostQuitMessage(0); return 0; default: return DefWindowProc(hWnd, message, wParam, lParam); } } // WndProc ============== but i get this errors: Compiling NONAME00.CPP: Error NONAME00.CPP 1: , expected Error NONAME00.CPP 3: Unable to open include file 'WINDOWS.H' Error NONAME00.CPP 4: Unable to open include file 'GDIPLUS.H' Error NONAME00.CPP 5: Declaration syntax error Error NONAME00.CPP 7: Unable to open include file 'MATH.H' Error NONAME00.CPP 8: Unable to open include file 'STDIO.H' Error NONAME00.CPP 10: Variable 'using' is initialized more than once Error NONAME00.CPP 10: Declaration syntax error Error NONAME00.CPP 13: Declaration syntax error Error NONAME00.CPP 100: Declaration syntax error ========= please please i need help ??? ???

Share this post


Link to post
Share on other sites
MaulingMonkey    1730
1) Wrap your code in [ source ] tags for readability
2) What are you building this with? The errors certainly don't look like VS2005's... you may still need to install/download the platform SDK
3) There are many better alternatives to GDI+, and C++ for that matter.
4) unsigned_int32 isn't a built in type, not even as an extension on most compilers that I'm aware of. If you're expecting this to be from some other header, move it *after* that header is included
5) using namespaces before your headers are all included is bad mojo and a nono, typically. You're also using the same namespace twice.

Share this post


Link to post
Share on other sites
Chrono1081    108
Quote:
Original post by NathanRunge
6) More descriptive thread titles will get a better response. :)


I agree. Most anything with abbreviations such as "plz" gets ignored.


Did you write this code or copy and paste it? What IDE are you using?

Also for C++ that code is pretty outdated. #include <stdio.h> is C, #include <iostream> is c++. Not to mention if this is your only code, its missing a main().

Share this post


Link to post
Share on other sites
jpetrie    13159
Quote:
Original post by Chrono1081
Quote:
Original post by NathanRunge
6) More descriptive thread titles will get a better response. :)


I agree. Most anything with abbreviations such as "plz" gets ignored.


Did you write this code or copy and paste it? What IDE are you using?

Also for C++ that code is pretty outdated. #include <stdio.h> is C, #include <iostream> is c++. Not to mention if this is your only code, its missing a main().


It has a WinMain, though.

The compiler error curiously lack line numbers, and convert file names to all caps. I wonder if the OP is using a 16-bit compiler? Either way, it does not appear as if the compiler has been properly informed of the directories to search for include directive resolution.

That and there are various bits of illegal code in there. You're going to have to provide more information, mostaqil cts, as well as more directed questions.

Share this post


Link to post
Share on other sites
Zahlman    1682
Quote:
Original post by mostaqil cts
Error NONAME00.CPP 10: Variable 'using' is initialized more than once


That can't possibly be a C++ compiler, can it?

Share this post


Link to post
Share on other sites
dwahler    313
Isn't "NONAME00.CPP" the default filename for Borland Turbo C++ (the DOS version)? That would explain the lack of support for "using namespace", and of course the missing Win32 headers.

Share this post


Link to post
Share on other sites
mostaqil cts    122
Ok K i didn't have a experience in C++


i will give you the main cod , which i have taken it from wab:

it is about "Edge Detection"

this is the main code, and there are an error with it:


=========




#define UNICODE
#include <windows.h>
#include <gdiplus.h>
#include <math.h>
#include <stdio.h>

using namespace Gdiplus;


VOID OnPaint(HDC hdc)
{
Graphics graphics(hdc);

Bitmap b(L"Calvin.jpg");
Bitmap* b2;

INT iWidth = b.GetWidth();
INT iHeight = b.GetHeight();

Rect rect(0,0,iWidth,iHeight);
b2 = b.Clone(rect,PixelFormat24bppRGB);


BitmapData bmData;
BitmapData bmData2;

b.LockBits(&rect,ImageLockModeRead | ImageLockModeWrite,PixelFormat24bppRGB,&bmData);
b2->LockBits(&rect,ImageLockModeRead |ImageLockModeWrite,PixelFormat24bppRGB,&bmData2);

int stride = bmData.Stride;

unsigned char * p = (unsigned char *)bmData.Scan0;
unsigned char * p2 = (unsigned char *)bmData2.Scan0;


int nOffset = stride - iWidth*3;
int nWidth = iWidth * 3;

int nPixel = 0, nPixelMax = 0;

p += stride;
p2 += stride;
int nThreshold = 0;

for(int y=1;y<iHeight-1;++y)
{
p += 3;
p2 += 3;

for(int x=3; x < nWidth-3; ++x )
{


nPixelMax = abs((p2 - stride + 3)[0] - (p2+stride-3)[0]);
nPixel = abs((p2 + stride + 3)[0] - (p2 - stride - 3)[0]);
if (nPixel>nPixelMax) nPixelMax = nPixel;

nPixel = abs((p2 - stride)[0] - (p2 + stride)[0]);
if (nPixel>nPixelMax) nPixelMax = nPixel;

nPixel = abs((p2+3)[0] - (p2 - 3)[0]);
if (nPixel>nPixelMax) nPixelMax = nPixel;

if (nPixelMax < nThreshold)
nPixelMax = 0;

/*if(nPixelMax > nThreshold && nPixelMax < 35)
nPixelMax = 0;

if(nPixelMax > 35)
nPixelMax = 255;*/

p[0] = (byte) nPixelMax;

++ p;
++ p2;

}

p += 3 + nOffset;
p2 += 3 + nOffset;
}



b.UnlockBits(&bmData);
b2->UnlockBits(&bmData2);

graphics.DrawImage(b2,0,0,iWidth,iHeight);
graphics.DrawImage(&b, iWidth+10, 0, iWidth, iHeight);

}


LRESULT CALLBACK WndProc(HWND, UINT, WPARAM, LPARAM);

INT WINAPI WinMain(HINSTANCE hInstance, HINSTANCE, PSTR, INT iCmdShow)
{
HWND hWnd;
MSG msg;
WNDCLASS wndClass;
GdiplusStartupInput gdiplusStartupInput;
ULONG_PTR gdiplusToken;

// Initialize GDI+.
GdiplusStartup(&gdiplusToken, &gdiplusStartupInput, NULL);

wndClass.style = CS_HREDRAW | CS_VREDRAW;
wndClass.lpfnWndProc = WndProc;
wndClass.cbClsExtra = 0;
wndClass.cbWndExtra = 0;
wndClass.hInstance = hInstance;
wndClass.hIcon = LoadIcon(NULL, IDI_APPLICATION);
wndClass.hCursor = LoadCursor(NULL, IDC_ARROW);
wndClass.hbrBackground = (HBRUSH)GetStockObject(WHITE_BRUSH);
wndClass.lpszMenuName = NULL;
wndClass.lpszClassName = TEXT("Edge Detection");

RegisterClass(&wndClass);

hWnd = CreateWindow(
TEXT("Edge Detection"), // window class name
TEXT("Edge Detection"), // window caption
WS_OVERLAPPEDWINDOW, // window style
CW_USEDEFAULT, // initial x position
CW_USEDEFAULT, // initial y position
CW_USEDEFAULT, // initial x size
CW_USEDEFAULT, // initial y size
NULL, // parent window handle
NULL, // window menu handle
hInstance, // program instance handle
NULL); // creation parameters

ShowWindow(hWnd, iCmdShow);
UpdateWindow(hWnd);

while(GetMessage(&msg, NULL, 0, 0))
{
TranslateMessage(&msg);
DispatchMessage(&msg);
}

GdiplusShutdown(gdiplusToken);
return msg.wParam;
} // WinMain


LRESULT CALLBACK WndProc(HWND hWnd, UINT message,
WPARAM wParam, LPARAM lParam)
{
HDC hdc;
PAINTSTRUCT ps;

switch(message)
{
case WM_CREATE:
//OnCreate();
return 0;

case WM_PAINT:
hdc = BeginPaint(hWnd, &ps);
OnPaint(hdc);
EndPaint(hWnd, &ps);
return 0;

case WM_DESTROY:
PostQuitMessage(0);
return 0;

default:
return DefWindowProc(hWnd, message, wParam, lParam);
}
} // WndProc



==============

THis are the eroor :



Compiling NONAME00.CPP:
Error NONAME00.CPP 4: Unable to open include file 'GDIPLUS.H'
Error NONAME00.CPP 5: Unable to open include file 'MATH.H'
Error NONAME00.CPP 6: Unable to open include file 'STDIO.H'
Error NONAME00.CPP 8: Declaration syntax error
Error NONAME00.CPP 13: Undefined symbol 'Graphics' in function OnPaint(unsigned int)
Error NONAME00.CPP 13: Statement missing ; in function OnPaint(unsigned int)
Error NONAME00.CPP 15: Undefined symbol 'Bitmap' in function OnPaint(unsigned int)
Error NONAME00.CPP 15: Statement missing ; in function OnPaint(unsigned int)
Error NONAME00.CPP 16: Undefined symbol 'b2' in function OnPaint(unsigned int)
Error NONAME00.CPP 18: Undefined symbol 'INT' in function OnPaint(unsigned int)
Error NONAME00.CPP 18: Statement missing ; in function OnPaint(unsigned int)
Error NONAME00.CPP 19: Statement missing ; in function OnPaint(unsigned int)
Error NONAME00.CPP 21: Undefined symbol 'Rect' in function OnPaint(unsigned int)
Error NONAME00.CPP 21: Statement missing ; in function OnPaint(unsigned int)
Error NONAME00.CPP 22: Undefined symbol 'b' in function OnPaint(unsigned int)
Error NONAME00.CPP 22: Undefined symbol 'rect' in function OnPaint(unsigned int)
Error NONAME00.CPP 22: Undefined symbol 'PixelFormat24bppRGB' in function OnPaint(unsigned int)
Error NONAME00.CPP 25: Undefined symbol 'BitmapData' in function OnPaint(unsigned int)
Error NONAME00.CPP 25: Statement missing ; in function OnPaint(unsigned int)
Error NONAME00.CPP 26: Statement missing ; in function OnPaint(unsigned int)
Error NONAME00.CPP 28: Undefined symbol 'ImageLockModeRead' in function OnPaint(unsigned int)
Error NONAME00.CPP 28: Undefined symbol 'ImageLockModeWrite' in function OnPaint(unsigned int)
Error NONAME00.CPP 28: Undefined symbol 'bmData' in function OnPaint(unsigned int)
Error NONAME00.CPP 29: Undefined symbol 'bmData2' in function OnPaint(unsigned int)
Error NONAME00.CPP 37: Undefined symbol 'iWidth' in function OnPaint(unsigned int)
Error NONAME00.CPP 37: Too many error or warning messages in function OnPaint(unsigned int)

Share this post


Link to post
Share on other sites
dwahler    313
mostaqil cts, what compiler are you using? There is simply no way you will get that code to compile on Turbo C++ for DOS. You can't expect to be able to generate 32-bit Windows object code with a 16-bit MS-DOS compiler, let alone one that was released almost 20 years ago.

Share this post


Link to post
Share on other sites
MaulingMonkey    1730
Quote:
Original post by MaulingMonkey
1) Wrap your code in [ source ] tags for readability
2) What are you building this with? The errors certainly don't look like VS2005's... you may still need to install/download the platform SDK


To expand on number 2: "...or switch to something that actually compiles modern C++".

Share this post


Link to post
Share on other sites
oler1s    585
Quote:
From OP
i will give you the main cod , which i have taken it from wab
Notice how our OP has no real question. Don't waste your time on this.

OP, refer to our homework policy. We don't do your homework.

Share this post


Link to post
Share on other sites
fastcall22    10846
Quote:
Original post by oler1s
Quote:
From OP
i will give you the main cod , which i have taken it from wab
Notice how our OP has no real question. Don't waste your time on this.

OP, refer to our homework policy. We don't do your homework.


I believe he's looking for explanations for the errors, but the information the OP provided you can't know for sure. I'm certain it has nothing to do with homework. (It seems like English isn't his primary language...)

To the OP:
If you are running an outdated compiler, there's a great free version of Microsoft Visual Studio 2008 Express, one of the best IDE's for windows.

Share this post


Link to post
Share on other sites
Chrono1081    108
Also to the OP what they mean by using source tags is you will want to type:

{source} before you paste your code (only instead of these { } , use [ ] instead)

then when you are at the end of your pasted code type {/source} (also using [ ] instead of { } )

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

Sign in to follow this