|
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++
|
|
|
|
|
Hi,
The code at codeguru: http://www.codeguru.com/Cpp/G-M/gdi/article.php/c3693/[^] optimizes quite nicely in VS2005. With speed optimization enabled, compiler intrinsics, and /ARCH:SSE the VS2005 compiler does a pretty damn good job at optimizing his code. Download the sample and give it a shot. 0 to 1% cpu usage on my laptop even when I set the timer to 1ms (of which the smallest quantum is around 10ms)
Hope it helps,
-Randor (David Delaune)
|
|
|
|
|
Btw:
You can modify the project properties at 'Output Files' and enable 'Assembler Output' as 'Assembly with Source Code /FAs'
Check out the beautiful asm code optimizations... MMX and SSE very nicely optimized by the compiler, I have been impressed with the optimizations of VS2005. I have nearly always been able to manually generate asm code by hand to outperform visual studio. This is the first compiler I have a hard time beating! Cant' wait to see VS2008 'Orcas' optimizer.
-Randor (David Delaune)
|
|
|
|
|
Hi,
you can mix the solutions.
first load the original icon as bitmap and rotate it 720 times,
store the bitmaps as 720 icons ( use CreateIcon() ),
than use the stored icons.
You need to do the computation only once at program start and avoid the
administration overhead of having 720 icons in the resource file.
Regards,
Georg
Regards,
Georg
|
|
|
|
|
Hello everyone,
I have developed a COM component using C++. And I need to invoke some functions in another DLL which is implemented in C#. I am wondering whether there are any tutorials or samples of how to do this correctly and safely?
I have this question because I noticed that the data types in C++ and C# are not the same -- how to make them compatible? This is the most of my concern.
thanks in advance,
George
|
|
|
|
|
So shouldn't that be "Calling a C++ function from a C#" ? Anyway once if you've made a function in COM you can very well call it a "COM function" rather than C++ function. And to answer your question, You can easily add or "referrence" your COM component in the C# project and start considering it a class. You create object from it, set event handlers access member variables, etc. But I suggest you have a look at here.
Introp[^]*
RCW[^]
CCW[^]
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,
I am talking about a different scenario -- invoking C# function from unmanaged C++ COM object. Any ideas or reference articles?
regards,
George
|
|
|
|
|
Hi George,
Little busy at work. The CCW is exactly meant for that. You may look into that. If you want a working sample them, I think Nishant Shivakumar has written nice articles about mixing up managed and unmanaged codes. You may give a dig at them. And one things is that you may look into any "unmanaged" code that access that managed code rather than trying to find "COM" calling a managed code. that's apparently if could do that in any unmanaged environment, then you should be able to do the same from COM which is of the same type right?.. So give a generic search key . Good luck
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,
Two more questions,
1. I have not found any articles written by Nishant Shivakumar from CodeProject, could you help to point them out please?
2. for your comments,
VuNic wrote: And one things is that you may look into any "unmanaged" code that access that managed code rather than trying to find "COM" calling a managed code. that's apparently if could do that in any unmanaged environment, then you should be able to do the same from COM which is of the same type right?
I think you mean accessing from unmanaged code to managed code is the same for both,
A. accessing from a normal native unmanaged application (or DLL) to managed code (e.g. C#);
B. accessing from native unmanaged COM code to managed code (e.g. C#).
Right?
regards,
George
|
|
|
|
|
I currently have a piece of code that parses and extracts data from WAV files using Windows fuctions like
mmioOpen
mmioDescend
mmioRead
mmioAscend
mmioClose
I now want to open and parse WAV files using an IStream interface. Is there an equivalent set of library functions or will I have to parse the files myself?
|
|
|
|
|
the first question you must answer is WHY? mmio* functions are specifically designed to handle MultiMediaInputOutput why make life hard for yourself?
|
|
|
|
|