Click here to Skip to main content
15,910,277 members
Home / Discussions / C#
   

C#

 
AnswerRe: how to connect MySql via network Pin
Saksida Bojan23-Sep-10 0:45
Saksida Bojan23-Sep-10 0:45 
GeneralRe: how to connect MySql via network Pin
Erdinc2723-Sep-10 1:46
Erdinc2723-Sep-10 1:46 
QuestionIcon for dll assembly Pin
Chesnokov Yuriy22-Sep-10 19:13
professionalChesnokov Yuriy22-Sep-10 19:13 
AnswerRe: Icon for dll assembly Pin
AspDotNetDev22-Sep-10 19:34
protectorAspDotNetDev22-Sep-10 19:34 
QuestionQuick C# Help Retrieve data using while (!sr.EndOfStream) Pin
d87c22-Sep-10 17:35
d87c22-Sep-10 17:35 
AnswerRe: Quick C# Help Retrieve data using while (!sr.EndOfStream) Pin
AspDotNetDev22-Sep-10 18:58
protectorAspDotNetDev22-Sep-10 18:58 
GeneralRe: Quick C# Help Retrieve data using while (!sr.EndOfStream) Pin
d87c22-Sep-10 19:05
d87c22-Sep-10 19:05 
GeneralRe: Quick C# Help Retrieve data using while (!sr.EndOfStream) Pin
AspDotNetDev22-Sep-10 19:17
protectorAspDotNetDev22-Sep-10 19:17 
QuestionRetrieve array items to use in NUnit Test Pin
mtn*rain22-Sep-10 15:01
mtn*rain22-Sep-10 15:01 
AnswerRe: Retrieve array items to use in NUnit Test Pin
Luc Pattyn22-Sep-10 15:37
sitebuilderLuc Pattyn22-Sep-10 15:37 
GeneralRe: Retrieve array items to use in NUnit Test Pin
mtn*rain22-Sep-10 15:39
mtn*rain22-Sep-10 15:39 
AnswerRe: Retrieve array items to use in NUnit Test Pin
Luc Pattyn22-Sep-10 15:44
sitebuilderLuc Pattyn22-Sep-10 15:44 
GeneralRe: Retrieve array items to use in NUnit Test Pin
mtn*rain22-Sep-10 15:48
mtn*rain22-Sep-10 15:48 
GeneralRe: Retrieve array items to use in NUnit Test Pin
Luc Pattyn22-Sep-10 15:59
sitebuilderLuc Pattyn22-Sep-10 15:59 
GeneralRe: Retrieve array items to use in NUnit Test Pin
mtn*rain22-Sep-10 16:02
mtn*rain22-Sep-10 16:02 
AnswerRe: Retrieve array items to use in NUnit Test Pin
AspDotNetDev22-Sep-10 16:07
protectorAspDotNetDev22-Sep-10 16:07 
GeneralRe: Retrieve array items to use in NUnit Test Pin
mtn*rain22-Sep-10 16:12
mtn*rain22-Sep-10 16:12 
GeneralRe: Retrieve array items to use in NUnit Test Pin
Paul Michalik22-Sep-10 20:47
Paul Michalik22-Sep-10 20:47 
Question3 way byte merge Pin
jkohler22-Sep-10 4:01
jkohler22-Sep-10 4:01 
Hi all,

I'm working with a machine vision package which uses a proprietary internal image format. Their package will convert to many common formats (jpg/bmp/png/etc) but this conversion is only done to disk and I want to do an in-memory conversion because the to-disk conversion is just plain too slow (>200ms).

Their format for 8bit color images is 3 separate planes (R,G&B) which easily combine into a 24bpp BitMap like this:

private static unsafe void CopyColorPlanes( BitmapData bmp, IntPtr _b, IntPtr _g, IntPtr _r )
{
    byte* imgPtr = (byte*)bmp.Scan0;

    //
    // single tasked version - one row at a time.....

    int h = bmp.Height;
    int w = bmp.Width;
    int s = bmp.Stride;
    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++ = *b++;
            *imgPtr++ = *g++;
            *imgPtr++ = *r++;
        }
        imgPtr += ( ( s / 3 ) - w ) * 3;  // ensures we're starting the row properly aligned
    }
}

This works well and is "reasonably" fast - a 1600x1200 color image conversion takes roughly 42ms on a 1.8MHz VIA C7 (the target system).

Two questions:
1) Does anyone see anything in the above method that could be tweaked (staying within "pure" C#) to make it faster? (I've already tried partitioning the source planes into halves and quarters to make them fit better in the CPU cache and while this has a small impact it's not significant and interestingly, doing columns in the outer loop runs about 10% faster on an AMD DualCore 4200 - go figger).

2) Is there some native Windows API that will do this job?

I know I probably end up crafting this in assembly but I view that as a last resort... and deadlines loom...
Subvert The Dominant Paradigm

AnswerRe: 3 way byte merge Pin
OriginalGriff22-Sep-10 4:19
mveOriginalGriff22-Sep-10 4:19 
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 

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.