473,386 Members | 1,803 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,386 software developers and data experts.

Convert Arraybyte to bitmap.

1
here is my code, I was trying to convert arraybyte to bitmap after placing some value in array and convert it back to bitmap, actually i'm working with bilinear interpolation. i really appreciate that if u can show me the right code to convert array to bitmap.(the code that in italic).

regards, mickle


Expand|Select|Wrap|Line Numbers
  1. int[,] arrayImage1 = new int [pictureBox1.Image.Height, pictureBox1.Image.Width];
  2. int[,] arrayImage2 = new int[pictureBox1.Image.Height, pictureBox1.Image.Width];
  3. Bitmap newbitmap = new Bitmap(pictureBox1.Image.Height, pictureBox1.Image.Width);
  4.             for (int i = 0; i < pictureBox1.Image.Height; i++) //y axis
  5.             {
  6.                 for (int j = 0; j < pictureBox1.Image.Width; j++) //x axis
  7.                 {
  8.                     Color image1 = redbitmap2.GetPixel(j, i);
  9.                     Color image2 = bluebitmap2.GetPixel(j, i);
  10.  
  11.                     byte ColorByteImage1 = RGB(image1);
  12.                     arrayImage1[j, i] = ColorByteImage1;
  13.                     byte ColorByteImage2 = RGB(image2);
  14.                     arrayImage2[j, i] = ColorByteImage2;
  15.  
  16.                     if (arrayImage1[j, i] != arrayImage2[j, i])
  17.                     {
  18.  
  19.                         int B1 = arrayImage1[j+1, i];
  20.                         int B2 = arrayImage1[j-1, i];
  21.                         int B3 = arrayImage1[j, i+1];
  22.                         int B4 = arrayImage1[j, i-1];
  23.  
  24.                         int array = (B1 + B2 + B3 + B4)/4;
  25.                         arrayImage1[j, i] = array;
  26.                     }
  27.  
  28.                 }
  29.             }
  30.  
  31.             TypeConverter tc = TypeDescriptor.GetConverter(typeof(Bitmap));
  32.             Bitmap newbitmap1 = (Bitmap)tc.ConvertFrom(arrayImage1);
  33.             pictureBox3.Image = newbitmap;
  34. //RGB uint
  35. private byte RGB(Color color)
  36. {
  37.     // Format the value of color - 0x00bbggrr
  38.     return ((byte)(((byte)(color.R) | ((byte)(color.G) << 8)) | (((byte)(color.B)) << 16)));
  39.  
  40. }
Apr 17 '11 #1
1 2667
GaryTexmo
1,501 Expert 1GB
You've got the R, G, and B values that you want to go into the Bitmap at any given pixel, so perhaps you can just use the SetPixel method on the Bitmap object.

http://msdn.microsoft.com/en-us/libr....setpixel.aspx
Apr 18 '11 #2

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

Similar topics

2
by: Eka Gautama | last post by:
Hi all, I need help for a sample code to convert a bitmap to byte as well from byte to bitmap.. Thanks for the help Eka
1
by: News VS.NET \( MS ILM \) | last post by:
Hello I have the following: Dim myBitmap As New Bitmap(600, 500) Q: How to convert a Bitmap to a Buffer() of Bytes
8
by: James Dean | last post by:
I have 1 bit per pixel information and i have the width and height of this data.Each bit corresponds to a 24 bit colour value. I want to convert this to 24bit per pixel bitmap. Do i need to...
3
by: Dennis | last post by:
I am trying to convert a bitmap to a JPEG MemoryStream and return a Byte array containing the resulting JPEG Image as follows: Public Function BmpToJPEG(ByVal BitMapIn As Bitmap, ByVal Quality As...
2
by: Wolfgang Hauer | last post by:
Hallo! Ich habe eine inmemory-bitmap. die ich leider in eine png-datei umwandeln muss. ich mache das jetzzt so: b = New...
2
by: =?Utf-8?B?UHJ6ZW1v?= | last post by:
Hi, I would like to have a web service method sending a bitmap image. But code like do not work: <WebMethod()_ Public Function GetBitmap() As Drawing.Bitmap Dim a As New...
5
by: stef | last post by:
hello I can find all kind of procedures to convert an array to a bitmap (wxPython, PIL), but I can't find the reverse, either - convert a bitmap to an array or - read a bitmap file to an...
2
by: Smokey Grindel | last post by:
when I do this code Dim HIcon As IntPtr = bmp.GetHicon to convert a Bitmap which is just a 16x16 image I pulled from a resource originally as an icon (16x16x32bit) then converted into a bitmap to...
1
by: deluxmilkman | last post by:
hi I know I can convert a mc to a bitmap with "cacheAsBitmap". Now I am wondering how I can convert a bitmap to a mc. I have a black and white bitmap, which I created from a vide still. now I...
2
by: Bill Fuller | last post by:
I have a Bitmap (bm) that I am able to save using, for example, bm.Save("file.jpg", System.Drawing.Imaging.ImageFormat.Jpeg). However, I would like to convert this to a byte array (byte). What is...
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: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
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...
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,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...

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.