Click here to Skip to main content
15,922,533 members
Home / Discussions / C#
   

C#

 
AnswerRe: Convert State to Abbreviation or Back... Pin
Leslie Sanford22-Feb-07 11:35
Leslie Sanford22-Feb-07 11:35 
GeneralTwo Things... Pin
code-frog22-Feb-07 11:51
professionalcode-frog22-Feb-07 11:51 
GeneralRe: Two Things... Pin
Leslie Sanford22-Feb-07 12:09
Leslie Sanford22-Feb-07 12:09 
GeneralRe: Convert State to Abbreviation or Back... Pin
Guffa22-Feb-07 12:10
Guffa22-Feb-07 12:10 
GeneralRe: Convert State to Abbreviation or Back... Pin
code-frog22-Feb-07 12:11
professionalcode-frog22-Feb-07 12:11 
Questionrefer to control on aspx page from ascx control Pin
digsy_22-Feb-07 8:49
digsy_22-Feb-07 8:49 
AnswerRe: refer to control on aspx page from ascx control Pin
Abisodun22-Feb-07 9:41
Abisodun22-Feb-07 9:41 
Questionconverting 24bits image into 8 bit grayscale image Pin
haseeb_saeed22-Feb-07 8:22
haseeb_saeed22-Feb-07 8:22 
Hello
I tried converting a 24bpprgb format image into 8bpp grayscale format… the code compiles well…it even saves the resulting 8bpp image but still the image is not gray scale rather it has some colors in it… would any one pls help… the code that I tried is kind of like this
code:

BitmapData b1 = b.LockBits(new Rectangle(0, 0,b.Width, b.Height), ImageLockMode.ReadWrite, PixelFormat.Format24bppRgb);

Bitmap newB = new Bitmap(b.Width,b.Height,PixelFormat.Format8bppIndexed);

BitmapData b2 = newB.LockBits(new Rectangle(0, 0, newB.Width, newB.Height),ImageLockMode.ReadWrite,PixelFormat.Format8bppIndexed);

int stride = b1.Stride;
int stride2 = b2.Stride;
unsafe
{
byte* ptr = ( byte *) b1.Scan0;;
byte* ptr2 = (byte*) b2.Scan0;;

int offset = stride - b.Width * 3;
int offset2 = Stride2 - newB.Width;

byte blue, red, green;
for (int i = 0; i <b.height; i++)
="" {
="" for="" (int="" j="0;" <="" b.width;="" j++)
="" blue="ptr[0];
" green="ptr[1];
" red="ptr[2];
" ptr2[0]="(byte)" (.299="" *="" +="" .587="" .114="" blue);
=""
="" if="" (ptr2[0]="" ptr3[0]="0;" if(ptr2[0]="">128)
ptr3[0]=1;

ptr+=3;
ptr2++;
}
ptr += offset;
ptr2 += offset2;
}
b.UnlockBits(b1);
newB.UnlockBits(b2);
newB.Save(@"C:\ima1.bmp");


Waiting for reply … thanx


haseeb

AnswerRe: converting 24bits image into 8 bit grayscale image Pin
Ed.Poore22-Feb-07 8:37
Ed.Poore22-Feb-07 8:37 
AnswerRe: converting 24bits image into 8 bit grayscale image Pin
Dan Neely22-Feb-07 8:55
Dan Neely22-Feb-07 8:55 
GeneralRe: converting 24bits image into 8 bit grayscale image Pin
haseeb_saeed22-Feb-07 23:09
haseeb_saeed22-Feb-07 23:09 
GeneralRe: converting 24bits image into 8 bit grayscale image Pin
Dan Neely23-Feb-07 2:10
Dan Neely23-Feb-07 2:10 
AnswerRe: converting 24bits image into 8 bit grayscale image Pin
Christian Graus22-Feb-07 13:42
protectorChristian Graus22-Feb-07 13:42 
GeneralRe: converting 24bits image into 8 bit grayscale image Pin
haseeb_saeed22-Feb-07 23:01
haseeb_saeed22-Feb-07 23:01 
Questionconverting 24bits image into 8 bit grayscale image Pin
haseeb_saeed22-Feb-07 8:21
haseeb_saeed22-Feb-07 8:21 
QuestionAdding web service reference in Visual Studio Pin
Jaguas22-Feb-07 8:06
Jaguas22-Feb-07 8:06 
AnswerRe: Adding web service reference in Visual Studio Pin
Michael Sync22-Feb-07 16:21
Michael Sync22-Feb-07 16:21 
GeneralRe: Adding web service reference in Visual Studio Pin
mail57235222-Feb-07 23:45
mail57235222-Feb-07 23:45 
GeneralRe: Adding web service reference in Visual Studio Pin
Michael Sync23-Feb-07 20:13
Michael Sync23-Feb-07 20:13 
QuestionSending Email from Desktop App Pin
TheJudeDude22-Feb-07 7:57
TheJudeDude22-Feb-07 7:57 
AnswerRe: Sending Email from Desktop App Pin
Ed.Poore22-Feb-07 8:42
Ed.Poore22-Feb-07 8:42 
GeneralRe: Sending Email from Desktop App Pin
TheJudeDude22-Feb-07 8:51
TheJudeDude22-Feb-07 8:51 
GeneralRe: Sending Email from Desktop App Pin
Ed.Poore22-Feb-07 9:07
Ed.Poore22-Feb-07 9:07 
AnswerRe: Sending Email from Desktop App Pin
Dave Kreskowiak22-Feb-07 9:09
mveDave Kreskowiak22-Feb-07 9:09 
GeneralRe: Sending Email from Desktop App [modified] Pin
TheJudeDude22-Feb-07 9:23
TheJudeDude22-Feb-07 9: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.