Click here to Skip to main content
15,901,283 members
Home / Discussions / C#
   

C#

 
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 
AnswerRe: 3 way byte merge Pin
englebart23-Sep-10 7:32
professionalenglebart23-Sep-10 7:32 
Don't use byte pointers for reading the source colors.

Maintain uint* or stretch to ulong* instead of using byte*.

Precalculate the single loop count, width*height/4 or /8 if you use ulong.

In the loop calculate 4 or 8 bytes at a time
   int work;
   
begin loop
   int tempRed = *_r++;   // you might also try int& tempRed = *_r++;
   //ditto for other colors
   // I am pretty sure that dotNet has strict endian rules, so this should be safe.
   *imgPtr++ = alpha | ((tempRed & 0x000000FF) << 16) | ((tempGreen & 0x000000FF) << 8)  | ((tempBlue & 0x000000FF));
   *imgPtr++ = alpha | ((tempRed & 0x0000FF00) << 8)  | ((tempGreen & 0x0000FF00))       | ((tempBlue & 0x0000FF00) >> 8);
   *imgPtr++ = alpha | ((tempRed & 0x00FF0000) )      | ((tempGreen & 0x00FF0000) >> 8)  | ((tempBlue & 0xFF0000) >> 16);
   *imgPtr++ = alpha | ((tempRed & 0xFF000000) >> 8)  | ((tempGreen & 0xFF000000) >> 16) | ((tempBlue & 0xFF000000) >> 24);
end loop

You will need some after-loop checks that perform the same logic for stragglers. (modulus 4 or 8).
switch(leftover_modulus) {
   case 3:
      *imgPtr++ = alpha | ((tempRed & 0x00FF0000) ) | ((tempGreen & 0xFF0000) >> 8) | ((tempBlue & 0xFF0000) >> 16);
      // fall thru
   case 2:
      ...
      // fall thru
   case 1:
      ...
      break;
   default:
      // nothing to do if 0 since it would have been handled in the loop
}

AnswerRe: 3 way byte merge Pin
JesperMadsen12323-Sep-10 8:32
JesperMadsen12323-Sep-10 8:32 
AnswerRe: 3 way byte merge Pin
starmerak23-Sep-10 20:47
starmerak23-Sep-10 20:47 
AnswerRe: 3 way byte merge Pin
oggenok6423-Sep-10 21:11
oggenok6423-Sep-10 21:11 
AnswerRe: 3 way byte merge Pin
englebart24-Sep-10 8:11
professionalenglebart24-Sep-10 8:11 
AnswerRe: 3 way byte merge Pin
Tim Yen26-Sep-10 14:35
Tim Yen26-Sep-10 14:35 
QuestionInstalling low level mouse hook in background thread Pin
PrefinMafin22-Sep-10 3:10
PrefinMafin22-Sep-10 3:10 
AnswerRe: Installing low level mouse hook in background thread Pin
Luc Pattyn22-Sep-10 3:22
sitebuilderLuc Pattyn22-Sep-10 3:22 
GeneralRe: Installing low level mouse hook in background thread Pin
PrefinMafin22-Sep-10 3:47
PrefinMafin22-Sep-10 3:47 
QuestionHow to enable in old application icon for windows 7 taskbar Pin
Chesnokov Yuriy22-Sep-10 2:37
professionalChesnokov Yuriy22-Sep-10 2:37 
AnswerRe: How to enable in old application icon for windows 7 taskbar Pin
Eddy Vluggen22-Sep-10 8:47
professionalEddy Vluggen22-Sep-10 8:47 
GeneralRe: How to enable in old application icon for windows 7 taskbar Pin
Chesnokov Yuriy22-Sep-10 9:43
professionalChesnokov Yuriy22-Sep-10 9:43 
GeneralRe: How to enable in old application icon for windows 7 taskbar Pin
Eddy Vluggen22-Sep-10 10:03
professionalEddy Vluggen22-Sep-10 10:03 
GeneralRe: How to enable in old application icon for windows 7 taskbar Pin
Chesnokov Yuriy22-Sep-10 19:11
professionalChesnokov Yuriy22-Sep-10 19:11 
GeneralRe: How to enable in old application icon for windows 7 taskbar Pin
Eddy Vluggen23-Sep-10 11:51
professionalEddy Vluggen23-Sep-10 11:51 
GeneralRe: How to enable in old application icon for windows 7 taskbar Pin
Chesnokov Yuriy23-Sep-10 19:06
professionalChesnokov Yuriy23-Sep-10 19:06 
GeneralRe: How to enable in old application icon for windows 7 taskbar Pin
Eddy Vluggen23-Sep-10 20:34
professionalEddy Vluggen23-Sep-10 20:34 
GeneralRe: How to enable in old application icon for windows 7 taskbar Pin
Chesnokov Yuriy23-Sep-10 20:45
professionalChesnokov Yuriy23-Sep-10 20:45 

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.