|
Hi all,
I'm using Visual C++.NET in a project involving image manipulation. The problem is that I'm getting different output using the MT or MTd Run-Time libraries. I've checked the inputs to the graphics functions (I can't check the functions itself because they're in a precompiled lib) and seem to be the same in both cases. Any suggestions on what's going on?
Thanks in advance.
|
|
|
|
|
Well.... VC++ uses different floating point libraries for the debug and release version. So you get different results. The main change is in precision.
Try applying breakpoints in release mode and check if you are getting the same result as in debug mode.
|
|
|
|
|
Anshul Solanki wrote:
VC++ uses different floating point libraries for the debug and release version.
OK, then I need to restate the question: could you point me to somewhere listing the main differences between debug and release libraries? Something I forgot to mention is that according to the theoretical results, the correct output is the one in debug mode. Otherwise I wouldn't be so concerned. Thanks again.
|
|
|
|
|
Hi
I want to overload [] [] operator for a Matrix class that I am writing. I think one of the solutions will overloading the operators incrementally. If someone has done this in past or has more ideas, please drop a line or bits of code.
generally, a templated version of overloading [ ] goes like:
e.g. template <class E> E& CMatrix<E>::operator [] (int index) const
{
return CMatrix::foo<E>[index];
}
Thanks
|
|
|
|
|
first of all, operator[][] doesn't exist in C++ !!!
what happens when you create a multi-dimensional array is in fact creating an array of arrays... d'you follow me ?!
TOXCCT >>> GEII power [toxcct][VisualCalc]
|
|
|
|
|
I think (but I'm really not sure, it's too long that I didn't do that ) that you will need to define a new class that is the one dimension array (like you mentionned there, CMatrix::foo). And then inside this class, override the [] operator also. But, for the CMatrix operator, it will not return the E template but a foo class... (and then on this return you apply the second operator[] from foo class that returns your E template element).
Ok, but as I said I'm not sure anymore...
But another suggestion: why don't you use the STL vector class ? It is a template class that can manage one dimensionnal arrays. Then you make a vector of vector and you have your matrix. The advantage is that you don't need to write it all again, that it has been tested by thousands of people, ...
|
|
|
|
|
There is no such thing as an operator[][].
However, you can simulate very easy.
All you have to do is create an operator[] that returns a pointer to your type.
inline T* operator[](int i) {return (m_data + (m_col*i));}
Here's a working example:
template < class T>
class dynamic_2d_array
{
public:
dynamic_2d_array(int row, int col):m_row(row),m_col(col), m_data((row!=0&&col!=0)?new T[row*col]:NULL){}
dynamic_2d_array(const dynamic_2d_array&src):m_row(src.m_row),m_col(src.m_col), m_data((src.m_row!=0&&src.m_col!=0)?new T[src.m_row*src.m_col]:NULL){
for(int r=0;r<m_row;++r)for(int c="0;c<m_col;++c)" (*this)[r][c]="src[r][c];
" }
="" ~dynamic_2d_array(){if(m_data)="" delete="" []m_data;}
="" inline="" t*="" operator[](int="" i)="" {return="" (m_data="" +="" (m_col*i));}
="" t="" const*const="" const="" (m_col*i));}
protected:
="" dynamic_2d_array&="" operator="(const" dynamic_2d_array&);
private:
="" int="" m_row;
="" m_col;
="" m_data;=""
};
you="" can="" download="" it="" from="" following="" link:
<a="" href="http://code.axter.com/dynamic_2d_array.h" rel="nofollow">http://code.axter.com/dynamic_2d_array.h[^]
Top ten member of C++ Expert Exchange.
http://www.experts-exchange.com/Cplusplus
|
|
|
|
|
I have got the following problem.
I have a put my resources in a DLL that is connected to my application at runtime.
Everything works fine, but as soon I put a custom control (p.e. Chris Maunder's Gridcontrol) in a dialog, that dialog won't come up.
Has anybody also encountered this problem and solved it?
|
|
|
|
|
Make your Dll an MFC extension dll.
|
|
|
|
|
Ours is an application using VC++ MFC. We need to draw an image in the window and this input image from the customer will be in .cgm format. Since windows meta file(wmf) format is microsoft supported one, we convert .cgm to .wmf file and import to our application. We load this wmf image using Loadpicture and render functions. We are using LPPICTURE object for drawing. The image clarity is not appreciable since it is not smooth. But if the same wmf image is inserted in MSEXCEL, it is smooth.So for this scenario, we need your inputs on
a) Is any other microsoft supported object(like LPPICTURE) available to draw the image?
b) Is any 3rd party tool available to draw the wmf file with smooth?
c) Is it possible to load .cgm file directly in VC++ MFC application?
|
|
|
|
|
Sud_83 wrote:
any other microsoft supported object(like LPPICTURE) available to draw the image?
see GetEnhMetaFileHeader and PlayEnhMetaFile
Image Toolkits | Image Processing | Cleek
|
|
|
|
|
Hi,
I have an application (in VC++ 6.0) wherein it displays the images in ListView. So the application starts displaying the images from the Top left corner (0,0).
Now I have added the manifest file (to give XP look to application) in applicatoin resource successfully. (as outlined in the below mentioned link http://www.codeguru.com/Cpp/controls/controls/article.php/c5227/[^])
The application is having the XP look but the images are displayed from the Bottom left corner.
Question:How to set the origin of the ListCtrl to top left corner (0,0) so that the images are displayed from the top left corner (0,0) ?
Thanks & Regards,
Neeraj
Thanks & Regards,
Neeraj
Thanks & Regards,
Neeraj
|
|
|
|
|
hi!
For example, i have a class CMyRichEditCtrl that extends CWnd . In this class, i declare a CRichEditCtrl membre.
In CMyRichEditCtrl , i've declared a function :
BOOL CEdataRichEdit::OnNotify(WPARAM wParam, LPARAM lParam, LRESULT* pResult)<br />
{<br />
if (wParam == IDC_RICH)<br />
{<br />
}<br />
return CWnd::OnNotify(wParam, lParam, pResult);<br />
}
In my dialog (MyDialogDlg ), i've some buttons, and OnNotify function too.
Question: I want to call a function (OnNotify for example) of MyDialogDlg in <big>(1)</big> ? How can i do?
thanhks for all help!
hzocm
|
|
|
|
|
Hi again,
Still rumbling on with that old problem? What you are about to do here is not such a bad idea, but I found this in msdn which might help you more: TN062[^]
Joel Holdsworth
Wanna give me a job this summer?
Check out my online CV and project history[^]
|
|
|
|
|
thanks for your help!
the old problem is fixed. If fact, we must call SetEventMask .
i saw article TN062 , but i don't know how to create a ON_NOTIFY_REFLECT with ClassWizard (or manual)?
Can u give me something more? For example : how to creat ON_NOTIFY_REFLECT , how dose that means its parameter?, and how to get it (parameters)?
thanks
hzocm
|
|
|
|
|
|
I have a CString mystring defined like this:
mystring="FFFFFFFFFFFFFFFF";//16 F
How can I convert programatically that to a LONLONG ?
Thanks for any help.
|
|
|
|
|
Good morning fardak. I've got some code for you here. Hopefully it will be less messed up than yesterday's effort:
LONGLONG result = 0;
int cursor = 0;
int length = _tcslen(mystring);
for(int i = 0; i < length; i++)
{
result <<= 4;
if(mystring[i] >= _T('0') && mystring[i] <= _T('9'))
result |= (mystring[i] - _T('0')) & 0x0F;
else if(mystring[i] >= _T('a') && mystring[i] <= _T('f'))
result |= (mystring[i] - _T('a') + 10) & 0x0F;
else if(mystring[i] >= _T('A') && mystring[i] <= _T('F'))
result |= (mystring[i] - _T('A') + 10) & 0x0F;
else if(mystring[i] != _T(' ') &&
mystring[i] != _T('\t'))
break;
cursor++;
if(cursor >= sizeof(result) * 2)
break;
} Hope this helps you.
Joel Holdsworth
Wanna give me a job this summer?
Check out my online CV and project history[^]
|
|
|
|
|
Good morning Joel,and thanks for your prompt answer.
My God I am not that fast programming!
I'll study your code try it and get back to you as soon as I can.
Have a nice day.
|
|
|
|
|
Just noticed one minor bug. The code should be like this:
LONGLONG result = 0;
int cursor = 0;
int length = _tcslen(mystring);
for(int i = 0; i < length; i++)
{
result <<= 4;
if(mystring[i] >= _T('0') && mystring[i] <= _T('9'))
result |= (mystring[i] - _T('0'));
else if(mystring[i] >= _T('a') && mystring[i] <= _T('f'))
result |= (mystring[i] - _T('a') + 10);
else if(mystring[i] >= _T('A') && mystring[i] <= _T('F'))
result |= (mystring[i] - _T('A') + 10);
else if(mystring[i] == _T(' ') ||
mystring[i] == _T('\t'))
continue;
else break;
cursor++;
if(cursor >= sizeof(result) * 2)
break;
} The reason I'm making all these mistakes, is that i've got no compiler to test this stuff on right now!
Joel Holdsworth
Wanna give me a job this summer?
Check out my online CV and project history[^]
|
|
|
|
|
Thanks.
I did not study the code yet,but both codes compile without error and both give the same result.
I put the code in a function and added these three lines to se the result.
///////////////////////
CString message;
message.Format("%16x",result);
SetDlgItemText(IDC_MYRESULT,message);//Edit trol
///////////////////////////////////
The string I gave is "fffffffffffffff" //16 f
The answer I've got is :
ffffffff //8f !!
So it is as if the high "ffffffff" are ignored !
Maybe the loop should be extended ??
|
|
|
|
|
Yeah, that's what you'd expect. As this article[^] explains putting %x will only cause an int (32 bits) to be printed not your LONGLONG (64 bits). You could try something like this instead:
message.Format("%8x%8x", (int)(result>>32), (int)(result & 0xFFFFFFFF)); I've simply split the upper and lower dwords out, and then printed them one after another!
Joel Holdsworth
Wanna give me a job this summer?
Check out my online CV and project history[^]
|
|
|
|
|
I changed the "message.Format(..)" as you suggested,and the code compiles,runs and gives the result expected(i.e both dwords are dislpayed in the edit control).
Thank you so much for your time and effort.
I am sure your skill will be soon appreciated by someone.
Good luck.
|
|
|
|
|
What about using:
message.Format("%I64x", ...);
"Opinions are neither right nor wrong. I cannot change your opinion. I can, however, change what influences your opinion." - David Crow
|
|
|
|
|