|
Im getting the byte[] from an Camera, and yes, its 100% in order R-G-B. For testing, i made a byte[] by hand in a test-project.
public byte[] makeImg()
{
int x = 0;
byte[] Img = new Byte[f_WIDTH * f_HEIGHT*3];
for (int i = 0; i < f_WIDTH * f_HEIGHT*3; i+=3, x++)
{
if (x == f_WIDTH)
{
x = 0;
}
if (x <= f_WIDTH/3)
{
Img[i] = Convert.ToByte(255);
Img[i + 1] = Convert.ToByte(0);
Img[i + 2] = Convert.ToByte(0);
}
if (x > f_WIDTH / 3 && x < (f_WIDTH / 3)*2)
{
Img[i] = Convert.ToByte(0);
Img[i + 1] = Convert.ToByte(255);
Img[i + 2] = Convert.ToByte(0);
}
if (x > (f_WIDTH / 3) * 2)
{
Img[i] = Convert.ToByte(0);
Img[i + 1] = Convert.ToByte(0);
Img[i + 2] = Convert.ToByte(255);
}
}
return Img;
}
When i print it on screen, or put it into a bmp-file, the colors in the resulting image are blue-green-red ... in that order.
|
|
|
|
|
I have put your test image generator code into a Windows Forms Application and I get a vertical RED stripe, then a vertical GREEN stripe then a vertical BLUE stripe. This is what I would expect.
Here is my code:
public partial class ByteArrayToImageForm : Form
{
private int f_WIDTH = 100;
private int f_HEIGHT = 100;
private byte[] testImageArray;
public ByteArrayToImageForm()
{
InitializeComponent();
this.testImageArray = this.MakeImage();
}
public byte[] MakeImage()
{
int x = 0;
byte[] Img = new Byte[f_WIDTH * f_HEIGHT * 3];
for (int i = 0; i < f_WIDTH * f_HEIGHT * 3; i += 3, x++)
{
if (x == f_WIDTH)
{
x = 0;
}
if (x <= f_WIDTH / 3)
{
Img[i] = 255;
Img[i + 1] = 0;
Img[i + 2] = 0;
}
if (x > f_WIDTH / 3 && x < (f_WIDTH / 3) * 2)
{
Img[i] = 0;
Img[i + 1] = 255;
Img[i + 2] = 0;
}
if (x > (f_WIDTH / 3) * 2)
{
Img[i] = 0;
Img[i + 1] = 0;
Img[i + 2] = 255;
}
}
return Img;
}
private void ByteArrayToImageForm_Paint(object sender, PaintEventArgs e)
{
int arrayIndex = 0;
int x = 0;
int y = 0;
Bitmap visibleBitmap = new Bitmap(this.f_WIDTH, this.f_HEIGHT, PixelFormat.Format24bppRgb);
while (arrayIndex < this.testImageArray.Length)
{
visibleBitmap.SetPixel(x, y,
Color.FromArgb(this.testImageArray[arrayIndex],
this.testImageArray[arrayIndex + 1],
this.testImageArray[arrayIndex + 2]));
x++;
if (x >= this.f_WIDTH)
{
x = 0;
y++;
}
arrayIndex += 3;
}
int drawX = (this.ClientRectangle.Width - visibleBitmap.Width) / 2;
int drawY = (this.ClientRectangle.Height - visibleBitmap.Height) / 2;
e.Graphics.DrawImage(visibleBitmap, drawX, drawY);
}
}
Try it out. **NOTE** I have dispensed with the Convert.ToByte parts from your code as they are not necessary, although it does not alter the output (I tried both ways).
So unless you were using Convert.ToByte because you were converting from int, for example, which might explain your problems, I am at a loss.
Sorry!
Henry Minute
Do not read medical books! You could die of a misprint. - Mark Twain
Girl: (staring) "Why do you need an icy cucumber?"
“I want to report a fraud. The government is lying to us all.”
|
|
|
|
|
Hi everyone,
I try to create Cubes with Analysis Services in Visual Studio (C#) 2005, but my problem is...
... I created the datasource, datasourcesight, the cube and dimensions, but if I try to compile it and add it to SQL Servermanagement Studio it means, that it can't be added to the server cause the name might me wrong...
Sorry I am from germany and so I only have the german errorlog:
Fehler 1 Das Projekt konnte aufgrund der folgenden Konnektivitätsprobleme nicht auf dem Server 'test' bereitgestellt werden: Es kann keine Verbindung hergestellt werden. Stellen Sie sicher, dass der Server ausgeführt wird.. Überprüfen oder aktualisieren Sie den Namen des Zielservers, indem Sie mit der rechten Maustaste im Projektmappen-Explorer auf das Projekt klicken. Wählen Sie 'Projekteigenschaften' aus, klicken Sie auf die Registerkarte 'Bereitstellung', und geben Sie dann den Namen des Servers ein.
... my knowledge: it just means that the connection with the server failed, because I typed the wrong servername into the project
greets,
Mschauder
|
|
|
|
|
Hi,
you've got the wrong forum. The front-end is Visual Studio, yes, but it's mainly used plug-in for that is: SQL Server Business Intelligence Development Studio. And so it's not C#.
Try to ask the question on database forum.
BTW: Is the name of your server really 'test' and not maybe 'localhost', check the project properties Deployment -> Target -> Server
greetz
|
|
|
|
|
Hi
How can I implement the Mimefilter in c#.
I had got some links related to these http://msdn.microsoft.com/en-us/library/aa767916(VS.85).aspx[^]
Is there any other information related to these?
actually I want to change the web page text on the fly, such that the user can see the changed text directly on browser?
How to do this
|
|
|
|
|
Hello..
i want to encrypt an assembly at run time using command prompt. And same assembly i want to decrypt using C# code.
If any one know then ..it will really helpful for me....
thanks
|
|
|
|
|
What have you tried so far?
Post some code and explain where you think it is failing.
Henry Minute
Do not read medical books! You could die of a misprint. - Mark Twain
Girl: (staring) "Why do you need an icy cucumber?"
“I want to report a fraud. The government is lying to us all.”
|
|
|
|
|
i tried Dot Fuscator from command prompt to encrypt the assembly.
The sample code for dotfuscator :
i am using c++ code to generate dll from c# class.
CString pathDot="C:\\Program Files\\Microsoft Visual Studio 9.0\\Application\\PreEmptive Solutions\\Dotfuscator Community Edition";
sprintf(command,"\"%s\\dotfuscator\" /in:c:\\IS500Licence\\Licence.dll /v",pathDot.GetBuffer(0));
system(command);
|
|
|
|
|
Hello,
I need to extract a carasteres from a picture (JPG for exemple), on position X=40, Y=60, Height = 10, Width=10, can you help me to do it? please help me, thank you verry mutch
|
|
|
|
|
Hi,
what did you try so far? Just send a little bit code.
Bye
|
|
|
|
|
The Tesseract OCR[^] might be of help to you. I've heard from a few ex-colleagues that it is actually a very good OCR engine.
It is a crappy thing, but it's life -^ Carlo Pallini
|
|
|
|
|
Hi All,
I have created a simple remoting server inside a Window Service as :
<pre>TcpChannel tcpChannel = new TcpChannel(8085);
ChannelServices.RegisterChannel(tcpChannel,true);
WellKnownServiceTypeEntry entry = new WellKnownServiceTypeEntry("RemotingWindowSrvc", "RemotingWindowSrvc.MailFormat", "MailFormat", WellKnownObjectMode.SingleCall);
RemotingConfiguration.RegisterWellKnownServiceType(entry);</pre>
Then we try and make call to this server in my client as:
<pre>private void GetRemoteObject()
{
TcpChannel chan = new TcpChannel();
ChannelServices.RegisterChannel(chan);
MailFormat obj = (MailFormat)Activator.GetObject(typeof(MailFormat), "tcp://localhost:8085/MailFormat");
obj.sendUserRegistration("...");
}
}</pre>
MailFormat: is the name of the Class, being called here.
But upon calling "obj.sendUserRegistration("...");", client hangs indefinitely.
please help me with this.
Thanks,
Puneet
|
|
|
|
|
how about attaching debugger to the server process and see in it, if something happens...
|
|
|
|
|
Hi,
Thanks a lot for the reply, I have been able to solve this problem.
It was hanging cause, it wasn't able to resolve the function name. But once I signed the assembly and deployed it in GAC, it was able to recognize it and call the function.
I am putting the code for your reference:
Dim ch As TcpChannel = New TcpChannel(8085)
ChannelServices.RegisterChannel(ch)
RemotingConfiguration.RegisterWellKnownServiceType( _
GetType(TrialClassLib.MailFormat), "myRemoteObject", WellKnownObjectMode.Singleton)
|
|
|
|
|
i am using this code for date,time ,day
txtdate.Value = System.DateTime.Now.ToLongDateString();
but it totally showing in single textboxt,but we want that
date show in different textbox and time in different
day in different.
so plz help me??????
|
|
|
|
|
DateTime now = DateTime.Now;
string date = now.ToString("dd.MM.yyyy");
string time = now.ToString("HH:mm:ss");
|
|
|
|
|
please try this one
textBox1.Text = System.DateTime.Now.ToShortDateString();
textBox2.Text = Regex.Replace(System.DateTime.Now.TimeOfDay.ToString(), @"(.*?)\.(.*)", "$1");
textBox3.Text = System.DateTime.Now.DayOfWeek.ToString();
|
|
|
|
|
Member 3216646 wrote: textBox1.Text = System.DateTime.Now.ToShortDateString();
textBox2.Text = Regex.Replace(System.DateTime.Now.TimeOfDay.ToString(), @"(.*?)\.(.*)", "$1");
textBox3.Text = System.DateTime.Now.DayOfWeek.ToString();
Not saying this is wrong (although a regex is a little heavy and unreadable for a simple task like this), but it is a good idea to use
DateTime dateNow = DateTime.Now; and then to work with "dateNow", rather than use "DateTime.Now" three separate times. The reason being that each time you use .Now it returns the current date and time - which could potentially be in a different hour, day, year, or even century. If you habitually use just the single time reference, then you remove a source of potential bugs in future code.
No trees were harmed in the sending of this message; however, a significant number of electrons were slightly inconvenienced.
This message is made of fully recyclable Zeros and Ones
|
|
|
|
|
I fully agree.
|
|
|
|
|
|
DateTime dtime_Now = new DateTime();
string str_Day = dtime_Now.Date.ToString();
string str_Time = dtime_Now.TimeOfDay.ToString();
TextBox tb_1 = new TextBox();
tb_1.Text = str_Day;
TextBox tb_2 = new TextBox();
tb_2.Text = str_Time;
|
|
|
|
|
Surely that should be
DateTime dtime_Now = new DateTime();
DateTime dtime_Now = DateTime.Now;
string str_Day = dtime_Now.Date.ToString();
string str_Time = dtime_Now.TimeOfDay.ToString();
TextBox tb_1 = new TextBox();
tb_1.Text = str_Day;
TextBox tb_2 = new TextBox();
tb_2.Text = str_Time;
What you have posted gives a date of 01/01/1901, or whatever the default date is.
Henry Minute
Do not read medical books! You could die of a misprint. - Mark Twain
Girl: (staring) "Why do you need an icy cucumber?"
“I want to report a fraud. The government is lying to us all.”
|
|
|
|
|
Henry Minute wrote: What you have posted gives a date of 01/01/1901, or whatever the default date is.
yes, u are right!
|
|
|
|
|
|
I think the Lounge is more appropriate for your thread.
Life is a stage and we are all actors!
|
|
|
|