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

.NET (Core and Framework)

 
GeneralRe: How to insert large amount of data to mysql using C#.net (fastest way) Pin
Dave Kreskowiak12-Jun-13 10:10
mveDave Kreskowiak12-Jun-13 10:10 
AnswerRe: How to insert large amount of data to mysql using C#.net (fastest way) Pin
Eddy Vluggen11-Jun-13 10:32
professionalEddy Vluggen11-Jun-13 10:32 
AnswerRe: How to insert large amount of data to mysql using C#.net (fastest way) Pin
Manu V Nath3-Jul-13 23:13
professionalManu V Nath3-Jul-13 23:13 
QuestionMTOM and .NET question Pin
Antessima10-Jun-13 5:01
Antessima10-Jun-13 5:01 
AnswerRe: MTOM and .NET question Pin
Eddy Vluggen11-Jun-13 10:21
professionalEddy Vluggen11-Jun-13 10:21 
GeneralRe: MTOM and .NET question Pin
Antessima12-Jun-13 2:19
Antessima12-Jun-13 2:19 
GeneralRe: MTOM and .NET question Pin
Eddy Vluggen12-Jun-13 8:05
professionalEddy Vluggen12-Jun-13 8:05 
QuestionSending Message To Mobile Using Any Free Api's In Asp.net C# Pin
coderTOcode10-Jun-13 3:18
coderTOcode10-Jun-13 3:18 
AnswerRe: Sending Message To Mobile Using Any Free Api's In Asp.net C# Pin
Eddy Vluggen11-Jun-13 10:25
professionalEddy Vluggen11-Jun-13 10:25 
AnswerRe: Sending Message To Mobile Using Any Free Api's In Asp.net C# Pin
Manu V Nath3-Jul-13 23:15
professionalManu V Nath3-Jul-13 23:15 
QuestionData Conversions Pin
Bram van Kampen9-Jun-13 14:17
Bram van Kampen9-Jun-13 14:17 
AnswerRe: Data Conversions Pin
Abhinav S9-Jun-13 16:33
Abhinav S9-Jun-13 16:33 
AnswerRe: Data Conversions Pin
Richard MacCutchan9-Jun-13 21:12
mveRichard MacCutchan9-Jun-13 21:12 
GeneralRe: Data Conversions Pin
Richard Deeming10-Jun-13 1:39
mveRichard Deeming10-Jun-13 1:39 
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 

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.