Click here to Skip to main content
15,896,153 members
Home / Discussions / .NET (Core and Framework)
   

.NET (Core and Framework)

 
GeneralRe: Data Conversions Pin
Richard MacCutchan10-Jun-13 1:44
mveRichard MacCutchan10-Jun-13 1:44 
AnswerRe: Data Conversions Pin
Richard Deeming10-Jun-13 1:40
mveRichard Deeming10-Jun-13 1:40 
GeneralRe: Data Conversions Pin
Bram van Kampen11-Jun-13 13:11
Bram van Kampen11-Jun-13 13:11 
AnswerRe: Data Conversions Pin
Ron Beyer10-Jun-13 3:07
professionalRon Beyer10-Jun-13 3:07 
QuestionExecution time difference between VB.Net and C# code Pin
TnTinMn9-Jun-13 11:36
TnTinMn9-Jun-13 11:36 
AnswerRe: Execution time difference between VB.Net and C# code Pin
Bram van Kampen9-Jun-13 14:37
Bram van Kampen9-Jun-13 14:37 
GeneralRe: Execution time difference between VB.Net and C# code Pin
TnTinMn9-Jun-13 16:00
TnTinMn9-Jun-13 16:00 
AnswerRe: Execution time difference between VB.Net and C# code Pin
Ron Beyer9-Jun-13 19:05
professionalRon Beyer9-Jun-13 19:05 
This is a really good job for a profiler, the difference may be something subtle like the way the C# compiler generates MSIL versus the VB one. Yes, even a line-for-line translation of exactly the same code as you've done above will have different MSIL (in contrast to what your other answer has given).

There are some performance improvements you can implement above. You convert the pixel data from an integer, to a color, back to an integer, then back to a color, then back to an integer

Pixel Data->ToARGB->BT_601->Convert.ToInt32->FromARGB->ToArgb

In my mind it would be simpler to use bit level math for this. Make the BT_601 take the integer data, like:
C#
private static int BT_601(int c)
{
    int gs = (((0x00FF0000 & c) >> 16) * 0.299) << 16) +
             (((0x0000FF00 & c) >> 8 ) * 0.587) << 8) +
             (((0x000000FF & c) * 0.114);
    return (0xFF000000 & c) | (gs << 16) | (gs << 8) | gs;
}


Which is much faster compiler wise than trying to use all those conversions and function calls.

You may also want to do LockBits twice, once with read permission (not read/write) and the next time with write permission (not read). The one-way access helps optimize access to the buffer. You can also get about a 2 time increase by using pointers and unsafe code. You can also try to wrap your for loop in an unchecked block, which will keep the framework from doing bounds checks each time you access the array.

modified 10-Jun-13 1:14am.

GeneralRe: Execution time difference between VB.Net and C# code Pin
TnTinMn10-Jun-13 3:59
TnTinMn10-Jun-13 3:59 
QuestionDisplay Comments in winforms Pin
Member 100156599-Jun-13 5:04
Member 100156599-Jun-13 5:04 
AnswerRe: Display Comments in winforms Pin
Abhinav S9-Jun-13 5:23
Abhinav S9-Jun-13 5:23 
QuestionHow The data by jquery Pin
hansraj.sm5-Jun-13 20:52
hansraj.sm5-Jun-13 20:52 
AnswerRe: How The data by jquery Pin
Richard MacCutchan5-Jun-13 21:15
mveRichard MacCutchan5-Jun-13 21:15 
AnswerRe: How The data by jquery Pin
Abhinav S5-Jun-13 22:14
Abhinav S5-Jun-13 22:14 
AnswerRe: How The data by jquery Pin
Pete O'Hanlon5-Jun-13 22:20
mvePete O'Hanlon5-Jun-13 22:20 
QuestionHow to defeat God Pin
Bram van Kampen5-Jun-13 15:02
Bram van Kampen5-Jun-13 15:02 
AnswerRe: How to defeat God Pin
Dave Kreskowiak5-Jun-13 15:13
mveDave Kreskowiak5-Jun-13 15:13 
AnswerRe: How to defeat God Pin
Pete O'Hanlon5-Jun-13 19:23
mvePete O'Hanlon5-Jun-13 19:23 
AnswerRe: How to defeat God Pin
Richard MacCutchan5-Jun-13 21:14
mveRichard MacCutchan5-Jun-13 21:14 
GeneralRe: How to defeat God Pin
Bram van Kampen7-Jun-13 0:25
Bram van Kampen7-Jun-13 0:25 
GeneralRe: How to defeat God Pin
Richard MacCutchan7-Jun-13 1:02
mveRichard MacCutchan7-Jun-13 1:02 
AnswerRe: How to defeat God Pin
dusty_dex6-Jun-13 6:59
dusty_dex6-Jun-13 6:59 
AnswerRe: How to defeat God Pin
RedDk6-Jun-13 12:12
RedDk6-Jun-13 12:12 
Questionhow can I make a online class ? Pin
barbodsoft4-Jun-13 6:02
barbodsoft4-Jun-13 6:02 
AnswerRe: how can I make a online class ? Pin
Pete O'Hanlon4-Jun-13 7:12
mvePete O'Hanlon4-Jun-13 7:12 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.