473,385 Members | 1,848 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,385 software developers and data experts.

Pixels(really important)

I have an array of int pixels in my c# program and i want to convert it into an image. The problem is i am converting java source code for a program into equivalent c# code. In java the line reads which displays the array of int pixels into image.

Image output = createImage(new MemoryImageSource(width, height, orig, 0, width));

can someone tell me the c# equivalent? Here orig is the array of int pixels. I searched the Bitmap class and there is a method called SetPixel but the problem is it takes a x , y coordinate number. But what i have in my code is an array of int pixels. Another weird thing is my orig array has negative number and they are way far away from 255. In java this is teh same case(meaning both the array in c# and java have equivalent value) and the values is workign fine in java.
But i cant get that line translated in c#. Please help .
Thank you
Dec 24 '08 #1
2 2212
mldisibio
190 Expert 100+
Unless someone posts a better suggestion, I would say you will have to loop thru the source array and set each pixel using the Bitmap.SetPixel method.

There is also the Bitmap.Bitmap(Int32, Int32, Int32, PixelFormat, IntPtr) Constructor where IntPtr is a pointer to an array of bytes holding the pixel data.
Dec 26 '08 #2
PRR
750 Expert 512MB
@n3ts3cur3
try this
Expand|Select|Wrap|Line Numbers
  1. Bitmap my = new Bitmap(@"C:\Bernese Oberland.jpg");
  2.  
  3.             MemoryStream ms = new MemoryStream();
  4.             my.Save(ms, System.Drawing.Imaging.ImageFormat.Jpeg);
  5. // ms=new new MemoryStream(yourByteArray);
  6.  
  7.             pictureBox1.Image= Image.FromStream(ms);
  8.  
  9.  
check Image.FromStream Method (Stream)
Dec 26 '08 #3

Sign in to post your reply or Sign up for a free account.

Similar topics

4
by: baruch | last post by:
Hello! I'm using PHP Version 4.3.3RC5-dev with GD Version bundled (2.0.15 compatible) to generated some graphics based on mysql data and to my surprise when I use the GD function imageline($im,...
7
by: Ana | last post by:
I just ran a report on a site I'm redesigning and came up with all these missing height/width tags. How important are they? Should I go through the trouble of making sure they're there? Ana
67
by: Scott Meyers | last post by:
I have a web site that, due to maintenance by several people, some of whom are fairly clueless about HTML and CSS, etc. (notably me), has gotten to the point where I'm pretty sure it's suffering...
1
by: Pierre | last post by:
Hi... again (it's a bad day) Here is the point, I draw ellipse on an image (a map) in order to map something. But what I really don't know is how to erase the ellipse if I don't want to map the...
4
by: serdar c | last post by:
hi everyone, i am writing a program for my scool project and i need to count the number of black pixels in a white empty picture box.. in the old visual basic there was a really simple command...
3
by: michael | last post by:
Hi, I am trying to write an ASP.NET web app, in Visual Basic.NET, using Visual Studio.NET 2004, .NET framework 1.1.4322 SP1 Running the project/app on localhost while in dev/write/debug stage ...
2
by: Mateo | last post by:
Hi! I have a little problem and I would appritiate some suggestions. I want to vrite C# (or VB.Net) program which does following: - takes one by one pixel (or few pixels at the time) and...
5
by: Tim Streater | last post by:
If I create an image thus: var myImg = new Image (); I can then do the following: myImg.src = "someimage.jpg"; But, I can't seem to find a way to manipulate the pixels of the image in...
7
by: Rick Merrill | last post by:
I need a web page in exact pixels height and width for use in standard def TV. Any ideas how?
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.