Click here to Skip to main content
15,886,919 members
Home / Discussions / C#
   

C#

 
GeneralRe: 3 way byte merge Pin
jkohler22-Sep-10 4:28
jkohler22-Sep-10 4:28 
AnswerRe: 3 way byte merge Pin
Ennis Ray Lynch, Jr.22-Sep-10 5:07
Ennis Ray Lynch, Jr.22-Sep-10 5:07 
GeneralRe: 3 way byte merge Pin
jkohler22-Sep-10 5:15
jkohler22-Sep-10 5:15 
GeneralRe: 3 way byte merge Pin
harold aptroot22-Sep-10 5:40
harold aptroot22-Sep-10 5:40 
GeneralRe: 3 way byte merge Pin
jkohler22-Sep-10 6:00
jkohler22-Sep-10 6:00 
GeneralRe: 3 way byte merge Pin
harold aptroot22-Sep-10 6:11
harold aptroot22-Sep-10 6:11 
AnswerRe: 3 way byte merge Pin
Chris Trelawny-Ross22-Sep-10 9:19
Chris Trelawny-Ross22-Sep-10 9:19 
GeneralRe: 3 way byte merge Pin
jkohler22-Sep-10 9:35
jkohler22-Sep-10 9:35 
I just tried the 32bpp image format which on my development system gives a ~5% improvement. Unfortunately, on the target system (VIA C7) it makes little measurable difference. I expect any gain in execution speed is consumed in the increase in bitmap size (adding an additional byte per pixel to a 1600x1200 image is a significant increase in terms of CPU cache, etc.).

Moving the loop invariant outside the loop does indeed make a small difference when running in the debugger but release code? No difference at all. And interstingly the 32bpp format does not require that little calculation to be done at all.

In case you're interested, the 32bpp image version:
private static unsafe void CopyColorPlanes32( BitmapData bmp, IntPtr _b, IntPtr _g, IntPtr _r )
{
    int* imgPtr = (int*)bmp.Scan0;

    const int h = bmp.Height;
    const int w = bmp.Width;
    const int alphaValue = 0xff << 24; // opaque

    byte* b = (byte*)_b;
    byte* g = (byte*)_g;
    byte* r = (byte*)_r;

    for ( int row = 0; row < h; row++ )
        for ( int col = 0; col < w; col++ )
            *imgPtr++ = alphaValue | *b++ | ( *g++ << 8 ) | ( *r++ << 16 );
}

Subvert The Dominant Paradigm

GeneralRe: 3 way byte merge Pin
Michael B. Hansen23-Sep-10 2:27
Michael B. Hansen23-Sep-10 2:27 
GeneralRe: 3 way byte merge Pin
ely_bob23-Sep-10 8:25
professionalely_bob23-Sep-10 8:25 
GeneralRe: 3 way byte merge Pin
JonHarrison23-Sep-10 2:27
professionalJonHarrison23-Sep-10 2:27 
GeneralRe: 3 way byte merge Pin
jkohler23-Sep-10 3:24
jkohler23-Sep-10 3:24 
GeneralRe: 3 way byte merge Pin
JonHarrison23-Sep-10 3:34
professionalJonHarrison23-Sep-10 3:34 
GeneralRe: 3 way byte merge Pin
harold aptroot22-Sep-10 9:51
harold aptroot22-Sep-10 9:51 
GeneralRe: 3 way byte merge Pin
Chris Trelawny-Ross22-Sep-10 11:04
Chris Trelawny-Ross22-Sep-10 11:04 
GeneralRe: 3 way byte merge Pin
harold aptroot22-Sep-10 11:42
harold aptroot22-Sep-10 11:42 
GeneralRe: 3 way byte merge Pin
Chris Trelawny-Ross22-Sep-10 12:02
Chris Trelawny-Ross22-Sep-10 12:02 
GeneralRe: 3 way byte merge Pin
harold aptroot22-Sep-10 12:25
harold aptroot22-Sep-10 12:25 
GeneralRe: 3 way byte merge Pin
Chris Trelawny-Ross22-Sep-10 12:33
Chris Trelawny-Ross22-Sep-10 12:33 
AnswerRe: 3 way byte merge Pin
philpalk23-Sep-10 3:10
philpalk23-Sep-10 3:10 
AnswerRe: 3 way byte merge Pin
[NL]PUR23-Sep-10 3:19
[NL]PUR23-Sep-10 3:19 
AnswerRe: 3 way byte merge - no joy in C# ville Pin
jkohler23-Sep-10 4:21
jkohler23-Sep-10 4:21 
AnswerRe: 3 way byte merge Pin
Michael Kingsford Gray23-Sep-10 4:36
Michael Kingsford Gray23-Sep-10 4:36 
AnswerRe: 3 way byte merge Pin
patbob23-Sep-10 6:13
patbob23-Sep-10 6:13 
GeneralRe: 3 way byte merge Pin
jkohler23-Sep-10 7:40
jkohler23-Sep-10 7:40 

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.