Click here to Skip to main content
15,914,111 members
Home / Discussions / C#
   

C#

 
QuestionHow to create a Bitmap image from a array of Pixel data.... Pin
Kiran Satish11-Oct-04 19:48
Kiran Satish11-Oct-04 19:48 
AnswerRe: How to create a Bitmap image from a array of Pixel data.... Pin
Anonymous12-Oct-04 2:09
Anonymous12-Oct-04 2:09 
Generalhow Pin
Yulianto.11-Oct-04 19:14
Yulianto.11-Oct-04 19:14 
GeneralRe: how Pin
McClamm12-Oct-04 11:53
McClamm12-Oct-04 11:53 
GeneralFind List View Item Pin
Popoxinhxan11-Oct-04 16:30
Popoxinhxan11-Oct-04 16:30 
QuestionHow to hide a form at the program startup? Pin
ting66811-Oct-04 15:54
ting66811-Oct-04 15:54 
AnswerRe: How to hide a form at the program startup? Pin
Alex Korchemniy11-Oct-04 16:35
Alex Korchemniy11-Oct-04 16:35 
GeneralHelp needed..Urgent.....using CreateBitmap function in c# Pin
Kiran Satish11-Oct-04 12:26
Kiran Satish11-Oct-04 12:26 
Hi all,

I am creting a Bitmap image by using a two dimensional array of pixel data.

here is the procedure that i have gone thru...

first I have read the height and width of the original image which is (2544 X 1650).. since 1650 is not divisible by 4 i have used extra 2 columns to make it 1652 which is divisible by 4 (my actual array is 2544x4952 [since for R =1650, G=1650, B=1650 and 2 extra columns]). Now after copying each pixel value in the array for each line at the end i am inserting zeros for the extra 2 columns. Can we use an int array of data for this function?...I have checked for the approximate size of the resulting imge which goes around 12MB less than the specified 16MB for this function).Now I am calling the CreateBitmap function as follows...

hBitmap = PlatformInvokeGDI32.CreateBitmap( Width, Height, 3, 24, PixelData);

but this function is returning me a null value.
Am i calling it right ( I mean arguments in the function). I am using 1650 as the value for width argument (is it right).

then I am doin...
m_Bitmap = System.Drawing.Image.FromHbitmap(hBitmap);

Please help me how can i create a bitmap image by using above functions....

here is my source code snippet...
...
int[,] PixelData;
int Height=0, Width=0, j=0;

if(DialogResult.OK == openFileDialog.ShowDialog())
{
IntPtr hBitmap; ChosenFile=openFileDialog.FileName; this.Text = ChosenFile; PixelData = ConvertFile(ref Height, ref Width);
hBitmap = PlatformInvokeGDI32.CreateBitmap( Width, Height, 3, 24, PixelData);
if (hBitmap!=IntPtr.Zero)
{
m_Bitmap = System.Drawing.Image.FromHbitmap(hBitmap);
}
else
j=0;//just for a break point i initialized it
this.AutoScroll = true;
this.AutoScrollMinSize = new Size ((int)(m_Bitmap.Width * Zoom), (int)(m_Bitmap.Height * Zoom));
this.Invalidate();
}

public class PlatformInvokeGDI32
{
#region Class Functions
[DllImport("gdi32.dll",EntryPoint="DeleteObject")]
public static extern IntPtr DeleteObject(IntPtr hDc);

[DllImport ("gdi32.dll",EntryPoint="CreateBitmap")]
public static extern IntPtr CreateBitmap
(int nWidth, int nHeight, uint cPlanes, uint BitsPerPixel, int[,] lpvBits);

#endregion
#region Public Constructor
#endregion
}

thanks in advance,

Suman
GeneralMSMQ over HTTP Pin
francis10011-Oct-04 11:02
francis10011-Oct-04 11:02 
QuestionCan you safely start a form on a new thread? Pin
eyoung7011-Oct-04 10:59
eyoung7011-Oct-04 10:59 
AnswerRe: Can you safely start a form on a new thread? Pin
eyoung7011-Oct-04 11:16
eyoung7011-Oct-04 11:16 
GeneralRe: Can you safely start a form on a new thread? Pin
Dave Kreskowiak11-Oct-04 15:30
mveDave Kreskowiak11-Oct-04 15:30 
QuestionHow to access a control on a form from another class? Pin
DTWC_Lawrence11-Oct-04 10:20
DTWC_Lawrence11-Oct-04 10:20 
AnswerRe: How to access a control on a form from another class? Pin
Heath Stewart11-Oct-04 10:52
protectorHeath Stewart11-Oct-04 10:52 
GeneralProblem reading Files Pin
ee9903511-Oct-04 8:24
ee9903511-Oct-04 8:24 
GeneralRe: Problem reading Files Pin
Mike Dimmick11-Oct-04 10:15
Mike Dimmick11-Oct-04 10:15 
GeneralTrying to copy a datatable... Pin
Carl Mercier11-Oct-04 7:54
Carl Mercier11-Oct-04 7:54 
GeneralRe: Trying to copy a datatable... Pin
Anonymous11-Oct-04 8:08
Anonymous11-Oct-04 8:08 
GeneralRe: Trying to copy a datatable... Pin
Carl Mercier11-Oct-04 8:16
Carl Mercier11-Oct-04 8:16 
GeneralSimple HTML editor for winforms Pin
Brett Slaski11-Oct-04 7:20
Brett Slaski11-Oct-04 7:20 
GeneralRe: Simple HTML editor for winforms Pin
Jacob Hammack11-Oct-04 10:53
Jacob Hammack11-Oct-04 10:53 
GeneralRe: Simple HTML editor for winforms Pin
Brett Slaski11-Oct-04 15:59
Brett Slaski11-Oct-04 15:59 
GeneralTime entry 'lost' in dtp Pin
DF_Bandit11-Oct-04 7:18
DF_Bandit11-Oct-04 7:18 
GeneralRe: Time entry 'lost' in dtp Pin
DF_Bandit11-Oct-04 12:59
DF_Bandit11-Oct-04 12:59 
GeneralTime stamp Pin
wk_vigorous11-Oct-04 6:51
wk_vigorous11-Oct-04 6:51 

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.