|
Some ideas of the top of my head..
Can you interleave the input data for the function _b,_g,_r so they might fit caches better?
Maybe you can unroll some of the loop, iterate in 12 bytes at a time 4 * 3, and store as 3 uint* operations...
The last of the column w % 4 (i think) must be performed by your current loop (between 0 and 3 operations).
|
|
|
|
|
The first I see is that
( ( s / 3 ) - w ) * 3;
is the same as
s - w * 3;
although the suggestion to move this outside the loop will save you more...
|
|
|
|
|
Looks like an ideal case for some loop unrolling. If say bmp.Width is always even, the inner col loop could be rewritten as
for ( int col = 0; col < w; col += 2 ) {
*imgPtr++ = *b++;
*imgPtr++ = *g++;
*imgPtr++ = *r++;
*imgPtr++ = *b++;
*imgPtr++ = *g++;
*imgPtr++ = *r++;
}
saving half the overhead of loop management. C# doesn't allow fallthrough in switch statements, otherwise Duffs device would be perfect here.
- turin
|
|
|
|
|
Another approach. Some of the other posts got this idea kicking...
Have one outer loop based on a block size that tries to optimize read and write cache sizes.
By working with a single color at a time you should optimize read hits.
A simple starting point of blocksize = 1 should be close to what you have now.
You are trading read cache hits for loop overhead. The correct block size might swing this in your favor.
loop totalsize/blocksize
output pointer = (set based on block size)
loop blocksize(red)
read one byte from red pointer (pointer += 1)
write one byte to output pointer (pointer +=3)
endloop blocksize(red)
output pointer = (set based on block size) + 1 offset to skip red
loop blocksize(green)
read one byte from green pointer (pointer += 1)
write one byte to output pointer (pointer +=3)
endloop blocksize(green)
output pointer = (set based on block size) + 2 offset to skip red and green
loop blocksize(blue)
read one byte from blue pointer (pointer += 1)
write one byte to output pointer (pointer +=3)
endloop blocksize(blue)
endloop totalsize/blocksize
Variations:
have the input pointers start at different offsets (thirds) within the blocksize
and wrap at the end. This will smooth write conflicts on the output pointer.
apply one thread per color - you would want these threads
to be preallocated and dedicated to the blit engine
|
|
|
|
|
Why dont you do a BlockCopy using the Buffer class?
[^]
[^]
|
|
|
|
|
I'm using a low level mouse hook to track mouse movement and clicks.
Main window installs the hook on it's thread and everything works until that window has to do more demanding tasks (it can be emulated with Thread.Sleep(1000) ) which causes the mouse to freeze for the duration of the process.
I thought to fix this by initialising the hook on different thread.
MSDN ( http://msdn.microsoft.com/en-us/library/ms644986(VS.85).aspx ) says "This hook is called in the context of the thread that installed it. The call is made by sending a message to the thread that installed the hook. Therefore, the thread that installed the hook must have a message loop."
The problem is I don't know how to set up a callback loop on the background thread.
Any help is appreciated.
|
|
|
|
|
You're looking at it in the wrong way. The normal approach is to have the main thread do all the GUI stuff, and delegate all long-winding computations (including Thread.Sleep) to other threads. That is the way to keep your app responsive no matter what.
|
|
|
|
|
That idea crossed my mind once and I will probably end up doing it, but still, any unexpected window lag will still result in mouse being frozen which is very very bad.
For the sake of learning, I'm still interested in how to achieve my first suggestion.
Is there any other way to make sure there is no risk of unresponsive mouse when hooking it?
|
|
|
|
|
There is an old application developed in Vista with icon for application and main form. However in windows 7 that icon is not displayed when the application is in task bar.
Чесноков
|
|
|
|
|
I'd expect the form-icon on the taskbar. Can you give us some more clues? Is there no icon at all, or are you seeing some kind of default-icon? What version of Weven are you running?
I are Troll
|
|
|
|
|
The default icon is in there, as though no icon was attached to application.
Though in a ALT+TAB windows switch dialog the icon is correct.
Windows 7 home premium.
Чесноков
|
|
|
|
|
Chesnokov Yuriy wrote: Though in a ALT+TAB windows switch dialog the icon is correct.
That's the application's icon. Sounds like your form doesn't have a custom icon, or it might not have loaded correctly.
How about creating a test-application? A small app that displays a form. Assign an icon (to the form!), compile it, and try it on Weven HP.
I are Troll
|
|
|
|
|
I need to enable that old VS2008 created application and converted to VS2010 to work in windows 7.
Any new application is displaying its icon correctly by all means
Чесноков
|
|
|
|
|
In the original app, is the icon set over the designer, or is it assigned from code?
I are Troll
|
|
|
|
|
from designer, project properties, application icon
Чесноков
|
|
|
|
|
That would only change the applications' icon. The form has it's own icon, and that's what's being displayed in the taskbar.
If it's not set, the default icon will appear.
I are Troll
|
|
|
|
|
The icon was also set in the Form->Icon property. I reassigned it again however and it appeared then.
Чесноков
|
|
|
|
|
Hi,
I'm doing a course of C#/ASP.
Getting my head around c# syntax is relatively straight forward
But the framework is set up with a namespace + class for every eventuality.
Once you know the class, then there are a set of static and dynamic methods that you use to do whatever you want to do.
How do most people get their heads around it. Is it about frequent use ? Clever spreadsheets or summary books?
All thoughts appreciated ?
Thanks
|
|
|
|
|
No. Just Google. Look for: MSDN classname.
Most often the first hit is the MSDN documentation page on the class you want, and it lists the namespace, as well as the DLL you need to reference.
|
|
|
|
|
Object Browser. If there is something you expect exists but you don't know the name of it, add some references to the most likely System assemblies and just use the object browser. That way you also see a lot of other classes along the way which may stick in your memory for the next time.
|
|
|
|
|
Seriously, I just search on the internet for the namespace of the class I am working with.
The funniest thing about this particular signature is that by the time you realise it doesn't say anything it's too late to stop reading it.
My latest tip/trick
Visit the Hindi forum here.
|
|
|
|
|
Smon the Vidd wrote: How do most people get their heads around it.
They don't. One doesn't learn "all the classes" in the framework by heart. Not only would it be a lot, it wouldn't be efficient.
Learn the basics and research specific tasks that you want to implement. Whether it's writing a file, or manipulating a stream, you'd guess that you'd need something from the IO namespace. If you didn't, you'd find it with a quick Google, or on MSDN.
Then you'd need to be able to translate that documentation to the context of your code. That's why you'd need to learn the basics.
Smon the Vidd wrote: Is it about frequent use ? Clever spreadsheets or summary books?
By doing, and hanging around on this site
I are Troll
|
|
|
|
|
for C# express visual studio 2008
i have SQL server local database and
i want connect this database to my windows control..
like textbox , combobox , listbox etc..
i want perform following operation like
insert , update, delete,
movefirst, movelast, moveprevious, movlast
please explain how can i do step by step...
from creating database to distribute
give me sample
thanks ...
jignesh
|
|
|
|
|
I think you're better of googling for a tutorial or on article on this matter than asking about it here.
|
|
|
|
|
Keep the data access methods away from the GUI.
|
|
|
|