Click here to Skip to main content
15,925,602 members
Home / Discussions / C#
   

C#

 
GeneralMedia Player SDK Pin
Christian Graus12-Oct-04 14:47
protectorChristian Graus12-Oct-04 14:47 
GeneralNot an answer, but an alternative. Pin
Matt Philmon12-Oct-04 18:02
Matt Philmon12-Oct-04 18:02 
GeneralRe: Media Player SDK Pin
Dave Kreskowiak12-Oct-04 18:11
mveDave Kreskowiak12-Oct-04 18:11 
GeneralRe: Media Player SDK Pin
Christian Graus13-Oct-04 9:05
protectorChristian Graus13-Oct-04 9:05 
GeneralDatagrid and Datatable and sorting, Winform Pin
Matt Philmon12-Oct-04 11:53
Matt Philmon12-Oct-04 11:53 
QuestionHow to specify HOSTNAME in sql connection string Pin
Darryl Borden12-Oct-04 10:11
Darryl Borden12-Oct-04 10:11 
GeneralRe: How to specify HOSTNAME in sql connection string Pin
Heath Stewart12-Oct-04 10:59
protectorHeath Stewart12-Oct-04 10:59 
QuestionCan anyone tell me whether this is right or wrong..? Pin
Kiran Satish12-Oct-04 10:04
Kiran Satish12-Oct-04 10:04 
Hi,

Atlast I have implemented my program to convert an array of Pixel data.
step1)- first of all My original image is a 1650x2544 (widthxheight) and i have stored all the pixel data into an array of (2544x1650).

step2)- I have created an empty Bitmap of respective height and width.

step3)- Now i copied respective pixel data fromt the array data into all the 3 planes (R,G,B). as i am creating a monochrome image i am copying the same value for each three R,G,B values.

step4)- returning the image...

can anyone tell me whether wht i am doin is correct...

here is the code...

private void File_Open(object sender, System.EventArgs e)
{
OpenFileDialog openFileDialog = new OpenFileDialog();
openFileDialog.InitialDirectory = "c:\\" ;
openFileDialog.RestoreDirectory = true ;

int[,] PixelData;
int Height=0, Width=0, j;

if(DialogResult.OK == openFileDialog.ShowDialog())
{
ChosenFile=openFileDialog.FileName;
PixelData = ConvertFile(ref Height, ref Width);
m_Bitmap =new Bitmap(Width,Height,PixelFormat.Format24bppRgb);
if (Display (m_Bitmap, PixelData))
{
this.AutoScroll = true;
this.AutoScrollMinSize = new Size ((int)(m_Bitmap.Width * Zoom), (int)(m_Bitmap.Height * Zoom));
this.Invalidate();
}
}
}

int[,] ConvertFile(ref int H, ref int W)
{
int Height=0, Width=0, RGBWidth=0, Value=0, i;
int[] LUT = new int[4096];
FileStream InStream = new FileStream(ChosenFile, FileMode.Open, FileAccess.Read);

long nBytesToRead = InStream.Length;
byte[] ByteArray = new byte[2];

for ( i=0; i<256; ++i)
{
LUT[j]=LUT[j+1]=LUT[j+2]=LUT[j+3]=LUT[j+4]=LUT[j+5]=LUT[j+6]=LUT[j+7]=LUT[j+8]=
LUT[j+9]=LUT[j+10]=LUT[j+11]=LUT[j+12]=LUT[j+13]=LUT[j+14]=LUT[j+15]=i;
j=j+16;
}

for (i=0; i<nbytestoread; i+="2)
{"
int="" nextbyte="(int)" instream.read(bytearray,="" 0,="" 2);
="" if="" (="" i="">=4 && i<=7)
{
if ( i==4)
Height = (int)BinaryToDecimal(ByteArray);
else
Width = (int)(BinaryToDecimal(ByteArray))/2;
}
else if ( i>=128 )
{
break;
}
}

H = Height;
W = Width;
RGBWidth = Width*3;
int[,] PixelData = new int[Height,Width];
for (int x=0; x<height; ++x)
{
for="" (int="" y="0;" y<width;="" ++y)
{
int="" nextbyte="(int)" instream.read(bytearray,="" 0,="" 2);
value="LUT[BinaryToDecimal(ByteArray)];
" pixeldata[x,y]="Value;
i" +="2;
if" (i="">=nBytesToRead)
break;
}
if (i>=nBytesToRead)
break;
}

return PixelData;
}

public static bool Display(Bitmap b, int[,] PixelData)
{
BitmapData bmData = b.LockBits(new Rectangle(0, 0, b.Width, b.Height), ImageLockMode.ReadWrite, PixelFormat.Format24bppRgb);
int stride = bmData.Stride;
System.IntPtr Scan0 = bmData.Scan0;
int j;

unsafe
{
byte * p = (byte *)(void *)Scan0;
int nOffset = stride - b.Width*3;
for ( int y=0; y< b.Height; ++y)
{
for ( int x=0; x< b.Width; ++x)
{
p[0] = (byte)(255-PixelData[y,x]);
p[1] = (byte)(255-PixelData[y,x]);
p[2] = (byte)(255-PixelData[y,x]); p += 3;
}
p += nOffset;
}
}

b.UnlockBits(bmData);
GrayScale (b);
return true;
}

But I am not getting the image tht i am supposed to get...Frown | :(
thanks in advance,

Suman
AnswerRe: Can anyone tell me whether this is right or wrong..? Pin
Christian Graus12-Oct-04 10:46
protectorChristian Graus12-Oct-04 10:46 
GeneralRe: Can anyone tell me whether this is right or wrong..? Pin
Kiran Satish12-Oct-04 13:34
Kiran Satish12-Oct-04 13:34 
GeneralRe: Can anyone tell me whether this is right or wrong..? Pin
Kiran Satish13-Oct-04 19:33
Kiran Satish13-Oct-04 19:33 
GeneralWord documents to PDF in C## Pin
house12-Oct-04 9:53
house12-Oct-04 9:53 
GeneralRe: Word documents to PDF in C## Pin
Christian Graus12-Oct-04 10:47
protectorChristian Graus12-Oct-04 10:47 
GeneralImage Rotation Pin
ahmadzafar12-Oct-04 9:52
ahmadzafar12-Oct-04 9:52 
GeneralRe: Image Rotation Pin
Christian Graus12-Oct-04 10:50
protectorChristian Graus12-Oct-04 10:50 
GeneralRe: Image Rotation Pin
yoaz13-Oct-04 6:57
yoaz13-Oct-04 6:57 
GeneralRe: Image Rotation Pin
ahmadzafar15-Oct-04 6:37
ahmadzafar15-Oct-04 6:37 
GeneralRe: Image Rotation Pin
yoaz17-Oct-04 6:42
yoaz17-Oct-04 6:42 
GeneralRe: Image Rotation Pin
ahmadzafar10-Dec-04 16:44
ahmadzafar10-Dec-04 16:44 
GeneralConverting from a short file name to a long one in C# Pin
dabs12-Oct-04 8:29
dabs12-Oct-04 8:29 
GeneralRe: Converting from a short file name to a long one in C# Pin
mav.northwind13-Oct-04 4:43
mav.northwind13-Oct-04 4:43 
GeneralQuick question about threads Pin
Bryant Stirling12-Oct-04 7:33
Bryant Stirling12-Oct-04 7:33 
GeneralRe: Quick question about threads Pin
Gary Thom12-Oct-04 7:51
Gary Thom12-Oct-04 7:51 
GeneralWindow Media Player Control Pin
RockRock12-Oct-04 6:47
RockRock12-Oct-04 6:47 
GeneralRe: Window Media Player Control Pin
Heath Stewart12-Oct-04 7:25
protectorHeath Stewart12-Oct-04 7:25 

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.