|
You need to allocate memory first:
results_text[0] = new char[6];
sprintf(...);
"A good athlete is the result of a good and worthy opponent." - David Crow
"To have a respect for ourselves guides our morals; to have deference for others governs our manners." - Laurence Sterne
|
|
|
|
|
moonraker928 wrote: i have a double and an array of char*. i used reinterpret_cast to convert the double into a char* and then stored it in a particular index.
Ouch.
If there was a programmer penalty box, you would be sent to it, and not allowed to use
reinterpret_cast for 2 months
Mark
Mark Salsbery
Microsoft MVP - Visual C++
|
|
|
|
|
Haha. Yes, I read about the dangers of using that - now I use sprintf(..) thanks to you guys!
--
dg
|
|
|
|
|
Error: Could not generate command line for the 32-bit C/C++ Compiler for 80x86 tool.
Any idea why this happens?
Note: I've enough disk space.
He's become a household word in the Lounge. A whole new phraseology has evolved. Post a link or reply with a smiley and rose, and you've made a "Satipsism". So what? It's an interesting thing about the Internet, the evolution (as in change, not progress) of tone, quality, terminology, etc.
-Marc Clifton.
Best wishes to Rexx[^
|
|
|
|
|
What if you restart VC? Rebuild too.
Mark
Mark Salsbery
Microsoft MVP - Visual C++
|
|
|
|
|
Mark Salsbery wrote: What if you restart VC?
As simple as that! I was not even patient enough to test this. I closed the workspace and reopened and got the same error again. Just closed the IDE and opened again. It's fine now. And sorry for the disturbance!
He's become a household word in the Lounge. A whole new phraseology has evolved. Post a link or reply with a smiley and rose, and you've made a "Satipsism". So what? It's an interesting thing about the Internet, the evolution (as in change, not progress) of tone, quality, terminology, etc.
-Marc Clifton.
Best wishes to Rexx[^
|
|
|
|
|
In VS 2003, they fixed it - the IDE "closes" for you (with a friendly message asking if you want to
report the problem), saving you the trouble LOL
(I've only had 2005 crash once since I started using it full-time a few weeks ago)
Mark
Mark Salsbery
Microsoft MVP - Visual C++
|
|
|
|
|
heh,
VS2002 does the same thing. Closes for you when it detects a problem. Unfortunately I am still maintaining a single project in which the high level decision makers will not allow me to upgrade the project to VS2005.
Maybe I'll ask again next year when Orcas comes out.
|
|
|
|
|
Randor wrote: still maintaining a single project in which the high level decision makers will not allow me to upgrade the project to VS2005
Sounds scary. What are you going to do if VS2002 takes a dump? Make sure the decision makers are to blame.
"Real programmers just throw a bunch of 1s and 0s at the computer to see what sticks" - Pete O'Hanlon
|
|
|
|
|
Hi,
I'm working on a project,and one of the requirements is to draw one of the icons
in a different angle every time that the angle is updated.
Is there any way to rotate the icon,or shall I use a bitmap instead of icon and blit the bitmap's pixels by myself(which can consume a lot of CPU?)?
With best regards,
Eli
|
|
|
|
|
The better way is to have different[rotated,straight & all] icons/images in the resource and use them at the same place.. that would give you an "animated" effect rather than manipulating it at runtime.
He's become a household word in the Lounge. A whole new phraseology has evolved. Post a link or reply with a smiley and rose, and you've made a "Satipsism". So what? It's an interesting thing about the Internet, the evolution (as in change, not progress) of tone, quality, terminology, etc.
-Marc Clifton.
Best wishes to Rexx[^
|
|
|
|
|
Hi VuNic,
Thanks for your quick reply.
My problem is that I need to rotate the icon is 360deg with resoultion of 0.5deg(i.e 720 icons...).
I'm sure that there is a way to rotate an icon during runtime,but I can't find it...
With best regards,
Eli
|
|
|
|
|
0.5 degrees? Clickety[^] This might help you.
He's become a household word in the Lounge. A whole new phraseology has evolved. Post a link or reply with a smiley and rose, and you've made a "Satipsism". So what? It's an interesting thing about the Internet, the evolution (as in change, not progress) of tone, quality, terminology, etc.
-Marc Clifton.
Best wishes to Rexx[^
|
|
|
|
|
Thanks again,
I read this article(and others...),but the problem is that each one of those projects
runs all over the pixels of the bitmap,which consume a lot of CPU...
Thats why I thought the rotating an icon will be much more efective...
Thanks anyway...
Eli
|
|
|
|
|
Welcome, we'd wait for an image specialist here
He's become a household word in the Lounge. A whole new phraseology has evolved. Post a link or reply with a smiley and rose, and you've made a "Satipsism". So what? It's an interesting thing about the Internet, the evolution (as in change, not progress) of tone, quality, terminology, etc.
-Marc Clifton.
Best wishes to Rexx[^
|
|
|
|
|
How big is the icon? GDI+ would make it simple to code.
Mark
Mark Salsbery
Microsoft MVP - Visual C++
|
|
|
|
|
eli15021979 wrote: 0.5deg(i.e 720 icons...)
What is "720 icons"?
Mark
Mark Salsbery
Microsoft MVP - Visual C++
|
|
|
|
|
Hi Mark,
Mark Salsbery wrote: What is "720 icons"?
VuNic wrote: The better way is to have different[rotated,straight & all] icons/images in the resource and use them at the same place.. that would give you an "animated" effect rather than manipulating it at runtime.
I need to be able rotate the icon 360 degrres , with resolution of 0.5 degrees , so if I want to
use Vunic's way , I need total of 720 icons (2 icons per 1 degree...).
I'm preety sure that there is a way to rotate the displayed icon,but still,I can't find
any article or post in the forum for the related issue...
Maybe you can help me???
With best regards,
Eli
|
|
|
|
|
Whats wrong with the link to the code I posted earlier?
-Randor (David Delaune)
|
|
|
|
|
Hi David,
I just finished reading this article,and it seems preety good.
I will give it a try...
But still,isn't any way to rotate an icon?
Thanks anyway for your quick and helpful reply.
With best regards,
Eli
|
|
|
|
|
Hi,
The link I posted is a very fast way to rotate a bitmap using the memory directly on the DIB. I think maybe you have a misunderstanding of what an ICON is. A icon is simply a bitmap... an array of bytes in memory. Its not a vector format such as SVG or a mathematical model of a shape such as flash. Vector image formats can be rotated extremely fast, however an ICON is not a vector. More on vector graphics: http://en.wikipedia.org/wiki/Vector_graphics[^]
An ICON is a raster format... as previous stated, this is an array of bytes. More about raster formats: http://en.wikipedia.org/wiki/Raster_graphics[^]
In essense what I am saying is that if you want to rotate a bitmap, there is no other way but to rotate all of the bytes representing the image. The question then becomes... 'How fast can I rotate all of those bytes in the multidimensional array'.
The answer is multimedia instructions such as MMX and SSE/SSE2/SSSE which allow you to manipulate multiple bytes in a single instruction. This is why I was pointing out in my previous post how well the code from Yves Maurer at codeguru was bei ng optimized. I was attempting to illustrate that the performance was very good.
In laymen terms, what I am saying is:
1.)A standard beginner level algorithm for rotating a 32x32 icon would be to move each and every pixel one at a time. 32 loops of 32 pixel movements.
2.) Utilizing multimedia instructions such as MMX/SSE/SSE2/SSSE you can manipulate multiple pixels at once. For example... instead of 32 iterations of 32 pixel movements; You may be able to optimize it to 32 iterations of 4/8 movements, depening on multimedia optimizations.
In the old days we had to do much of the asm code ourselves, however beginning with VS2005 many of us asm programmers began seeing that the Visual studio optimizer was doing a hell of a good job.
The code implemented by Yves Maurer can optimize very well, I would recommend using it for your bitmap rotation. Yes there may be slightly more efficient implementations somewhere out on the web, but the margin of gain will be small.
-Randor (David Delaune)
|
|
|
|
|
Hi David,
WOW - this is all I have to say...(and thanks also... ).
All I wanted is to know if there is an API which do the rotation,
but from the code you gave me through your post,and with your [detailed] explanation,
I think I can solve my problem.
Thanks again,
and keep the good work by helping others.
With best regards,
Eli
|
|
|
|
|
|
Hi again,
Mark Salsbery wrote: What is the icon's dimensions and how often (per-second) does it get rotated?
Icon's size is 32X32 or 64X64.
Refressh rate is 4Hz(every 250msec).
I read the article from Randor's link and it seems to work,
But I think that rotating the icons instead of drawing bitmaps is more efficient...(I'm sure
that the people from MS can do the work better than me.....or not?;P).
I'm not familiar with GDI+(only GDI),but it is always good to learn something new...
Thanks,again...
With best regards,
Eli
|
|
|
|
|
You probably have your solution by now, but just to provide another option, here's GDI+ code
that rotates an icon (in a window) around its center point, 360 degrees at 0.5 degree intervals:
HICON hIcon = (HICON)::LoadImage(AfxGetInstanceHandle(), MAKEINTRESOURCE(IDI_MYICON), IMAGE_ICON, 96, 96, 0);
Gdiplus::Bitmap SrcBitmap(hIcon);
Graphics DstGraphics(*this);
REAL angle = 0.0f;
for (int i = 0; i < 720; ++i)
{
DstGraphics.ResetTransform();
DstGraphics.RotateTransform(angle);
DstGraphics.TranslateTransform(SrcBitmap.GetWidth()/2.0f, SrcBitmap.GetWidth()/2.0f, MatrixOrderAppend);
DstGraphics.DrawImage(&SrcBitmap, -((INT)SrcBitmap.GetWidth()/2), -((INT)SrcBitmap.GetHeight()/2), SrcBitmap.GetWidth(), SrcBitmap.GetHeight());
angle += 0.5f;
} Mark
Mark Salsbery
Microsoft MVP - Visual C++
|
|
|
|