|
Thanks Luc, the Longitude (-180 to +180) has the same scaling.
I can get the code running OK on Windwos but when ported to Unix (using a Gnu complier) the program bombs out.
Debuggin a bit limited hence the use of Windows for the development.
|
|
|
|
|
Andy202 wrote: the Longitude (-180 to +180) has the same scaling.
not sure what you are saying here. the longitude range has to cover 360 degrees (either -180 to +180 or 0 to +360), so it could be latitude uses the same scale factor, but then your opening statement (about MIN and MAX) isn't accurate for latitude.
OTOH if the scale factor is different for lat and lon, that would justify why the 180 (or 360) isn't incorporated in the magic constant.
Andy202 wrote: when ported to Unix (using a Gnu complier) the program bombs out.
A different compiler may generate different code, e.g. it could emit code that does check for overflows at run-time.
[ADDED] So far you have not specified where in the code it crashes. [/ADDED]
I can only suggest you:
1. include some logging statements so you can watch the numbers till the program crashes.
2. perform some unit tests (a simple loop over the range of interest should be easily implemented).
Taken together, that will clarify what goes on.
|
|
|
|
|
normally c-compilers cast from left to right (implicit). if yours don't - cast yourself (explicit):
positionData.msgPosLat = (int)(lat/(BEARING_SCALING * 180.0));
// (int)(double/(double*double))
AND
lat = ( (double)positionData.msgPosLat * (BEARING_SCALING * 180.0));
// (double*(double*double))
// hint: don't define twice (BEARING_SCALING)
have a nice day.
|
|
|
|
|
hi guys,,,
i'm a newbie in MFC so i'm need your advice to complete final project about identification signature. in this time i have problem about how to save image from picture box in MFC. this is my code used in MFC. this code not save image from picturebox. what's wrong with my code???
void SaveBitmapToFile( BYTE* pBitmapBits, LONG lWidth, LONG lHeight,WORD wBitsPerPixel, LPCTSTR lpszFileName );
void CSaveimageDlg::OnSave()
{
// TODO: Add your control notification handler code here
CDC *pDC = m_pic1.GetDC();
CDC dcMem1;
CRect rect;
m_pic1.GetClientRect(rect);
HDC hdc;
HBITMAP hBitmap = NULL;
BITMAP bm;
CBitmap Bitmap;
m_pic1.SetBitmap(Bitmap);
Bitmap.CreateBitmap(200 ,200,1,24,NULL);
m_bmpBitmap.GetBitmap(&bm);
//Bitmap.GetBitmap(&bm);
Bitmap.GetObject( sizeof( BITMAP ), &bm );
unsigned char *pData = new unsigned char [bm.bmHeight*bm.bmWidthBytes];
SaveBitmapToFile(pData,bm.bmHeight,bm.bmWidth,24,(LPCTSTR)_T("a.bmp"));
delete []pData;
}
void CSaveimageDlg::SaveBitmapToFile(BYTE *pBitmapBits, LONG lWidth, LONG lHeight, WORD wBitsPerPixel, LPCTSTR lpszFileName)
{
BITMAPINFOHEADER bmpInfoHeader = {0};
bmpInfoHeader.biSize = sizeof(BITMAPINFOHEADER);
bmpInfoHeader.biBitCount = wBitsPerPixel;
bmpInfoHeader.biClrImportant = 0;
bmpInfoHeader.biClrUsed = 0;
bmpInfoHeader.biCompression = BI_RGB;
bmpInfoHeader.biHeight = lHeight;
bmpInfoHeader.biWidth = lWidth;
bmpInfoHeader.biPlanes = 1;
bmpInfoHeader.biSizeImage = lWidth* lHeight * (wBitsPerPixel/8);
BITMAPFILEHEADER bfh = {0};
bfh.bfType=0x4D42;
bfh.bfType = 'B'+('M' << 8);
bfh.bfOffBits = sizeof(BITMAPINFOHEADER) + sizeof(BITMAPFILEHEADER);
bfh.bfSize = bfh.bfOffBits + bmpInfoHeader.biSizeImage;
HANDLE hFile = CreateFile( lpszFileName,GENERIC_WRITE, 0,NULL, CREATE_ALWAYS, FILE_ATTRIBUTE_NORMAL,NULL);
if( !hFile ) // return if error opening file
{
return;
}
DWORD dwWritten = 0;
WriteFile( hFile, &bfh, sizeof(bfh), &dwWritten , NULL );
WriteFile( hFile, &bmpInfoHeader, sizeof(bmpInfoHeader), &dwWritten, NULL );
WriteFile( hFile, pBitmapBits, bmpInfoHeader.biSizeImage, &dwWritten, NULL );
CloseHandle( hFile );
}
|
|
|
|
|
1.) width != byte_width! byte_width == (width*(bitsperpixel/8)+3)&~3 (4byte boundary)
2.) call GetBitmapBits to get the bitmap content before save.
have a nice day.
|
|
|
|
|
Hello
Try this.
http://www.ucancode.net/Visual_C_Codes/MFC-Example-CreateFile-WriteFile-save-memory-dc-bitmap-file.htm
instead of memdc, you can call your picture box dc.
Thanks
A. Gopinath.
|
|
|
|
|
thx for your answer sir..
but after i try the code, i can't find image c://temp.bmp.
can u tell me , how to the code work in MFC to save a image di picturebox.
my problem : i will load a image to picturebox in MFC then i'm want to save it.
can u give sample code about my problem??
Regard's
Johannes.
|
|
|
|
|
Thx sir..
but i dont understand..
Can you explain in detail the program...
Regard
Johannes
|
|
|
|
|
Hello
try by sending this hDC to save. I didn't tried this. check whether it is working or not.
HDC hDC=GetDC(GetDlgItem(IDC_PICTUREBOX); //------- id for your picture box.
Save...... (hDC, ...);
Thanks
A. Gopinath.
|
|
|
|
|
sir, i got a error.. "GetDC' : function does not take 1 parameters"
how about it??
|
|
|
|
|
Hello,
sorry for delay. instead of HDC you can use CClientDC. that will work.
Regards,
A. Gopinath.
|
|
|
|
|
hi
i defined an accelerator Ctrl+T to generate ID_TMPDLG. i put
ON_COMMAND(ID_TMPDLG, &Ct2App::OnTmpDlg)
but the function is not called. i tried to see whether to message for the accelerator is generated correctly and i tested it in:
BOOL Ct2App::PreTranslateMessage(MSG* pMsg)
{
if (pMsg->message == WM_KEYDOWN && pMsg->wParam == 'T')
return CWinAppEx::PreTranslateMessage(pMsg);
return CWinAppEx::PreTranslateMessage(pMsg);
} by defining a break point, i realized that the line is hit and the message is produced correctly. but i don't know why the command ID_TMPDLG is not generated or received by the application. i tried to handle the command in another places like main frame and child view, but it didn't help and the command is not still generated or received. i don't know whether the accelerator message is not converted into the command or the message is lost somewhere.
what can i do?
thx
|
|
|
|
|
1.) create an accelerator resource.
2.) load them: _haccel = LoadAccelerator(0,MAKEINTRESOURCE(<idaccel_res>))
3.) translate them by calling TranslateAccelerator()
have a nice day.
|
|
|
|
|
oh thanx
so u mean my defined accelerator is not loaded or is not translated?
i put it in the only one pre-existing accelerator list with the id of IDR_MAINFRAME. if it's not loaded the other defined accelerators in the list must also not work, but they do. for example Ctrl+S brings up the Save As dialog, etc.
how can i justify this and how can i check that whether an accelerator is loaded or translated properly and where in the program does this happen?
thx
|
|
|
|
|
"so u mean my defined accelerator is not loaded or is not translated?"
yes indeed - set a breakpoint at the TranslateMessage of the base class. enshure your accelerators are loaded. it seems only the predefined accelerators will work.
good luck.
|
|
|
|
|
i couldn't find TranslateMessage! it seems to be an API function, not belonging to any class. TranslateMessage of what class u mean?
|
|
|
|
|
Hi,
how do i receive full path of a specified process with it's name.
with Process32First and Process32Next functions, i will receive the name of specified process (the szExeFile member of PROCESSENTRY32 struct)
but to have full path?
please help me.
Zo.Naderi-Iran
|
|
|
|
|
You may call GetModuleFilenameEx[^] (after calling OpenProcess[^] for retrieving process handle from process id).
If the Lord God Almighty had consulted me before embarking upon the Creation, I would have recommended something simpler.
-- Alfonso the Wise, 13th Century King of Castile.
This is going on my arrogant assumptions. You may have a superb reason why I'm completely wrong.
-- Iain Clarke
[My articles]
|
|
|
|
|
i include the psapi header:
#include psapi.h
but it is an error : unresolved externals
?
Zo.Naderi-Iran
modified on Thursday, December 9, 2010 6:39 AM
|
|
|
|
|
Did you link with Psapi.lib?
If the Lord God Almighty had consulted me before embarking upon the Creation, I would have recommended something simpler.
-- Alfonso the Wise, 13th Century King of Castile.
This is going on my arrogant assumptions. You may have a superb reason why I'm completely wrong.
-- Iain Clarke
[My articles]
|
|
|
|
|
no, only include psapi.h
Zo.Naderi-Iran
|
|
|
|
|
The try to link with the library (select Project->Project Properties menu item, then, on the newly appeared window, choose Configuration Properties->Linker->Input , finally add Psapi.lib to the Additional Dependecies list).
If the Lord God Almighty had consulted me before embarking upon the Creation, I would have recommended something simpler.
-- Alfonso the Wise, 13th Century King of Castile.
This is going on my arrogant assumptions. You may have a superb reason why I'm completely wrong.
-- Iain Clarke
[My articles]
|
|
|
|
|
it is ok, thank you
Zo.Naderi-Iran
|
|
|
|
|
You are welcome.
If the Lord God Almighty had consulted me before embarking upon the Creation, I would have recommended something simpler.
-- Alfonso the Wise, 13th Century King of Castile.
This is going on my arrogant assumptions. You may have a superb reason why I'm completely wrong.
-- Iain Clarke
[My articles]
|
|
|
|
|
Including a header file and linking with a library are two separate things.
"One man's wage rise is another man's price increase." - Harold Wilson
"Fireproof doesn't mean the fire will never come. It means when the fire comes that you will be able to withstand it." - Michael Simmons
"Man who follows car will be exhausted." - Confucius
|
|
|
|