C# app - No UI and what's the Bitmap Depth

.NET Edition of the F-IN-BOX
pvns
Posts: 1
Joined: Wed Mar 28, 2007 7:35 pm

C# app - No UI and what's the Bitmap Depth

Postby pvns » Wed Mar 28, 2007 7:40 pm

We are experimenting with creating a C# console application that grabs bitmaps from the SWF. My questions are:

1) can we use F-IN-Box with absolutely no UI?

2) What would the bitmap depth be in this configuration? 5:6:5, 32 bit, ??

3) We would really like to use RGB 24 bit. Can we tell F-IN-Box to provide this?

thanks,
Brian

Softanics
Site Admin
Posts: 1402
Joined: Sat Sep 18, 2004 3:03 am
Location: Russia, St. Petersburg
Contact:

Re: C# app - No UI and what's the Bitmap Depth

Postby Softanics » Thu Mar 29, 2007 9:58 am

Thank you for your questions.

pvns wrote:1) can we use F-IN-Box with absolutely no UI?


You should create a window, but you can hide it.

pvns wrote:2) What would the bitmap depth be in this configuration? 5:6:5, 32 bit, ??


f_in_box__control.GetBitmap() returns System.Drawing.Bitmap which is created by System.Drawing.Bitmap.FromHbitmap. So it's a GDI bitmap.

pvns wrote:3) We would really like to use RGB 24 bit. Can we tell F-IN-Box to provide this?


Using f_in_box__control.GetBitmap() you get a bitmap, than you can get pixels in this format using LockBits method:

Code: Select all

System.Drawing.Bitmap bmp = f_in_box__control1.GetBitmap();

const System.Drawing.Imaging.PixelFormat pixel_format = System.Drawing.Imaging.PixelFormat.Format24bppRgb; // if you need 24 bits; System.Drawing.Imaging.PixelFormat contains many others format

System.Drawing.Imaging.BitmapData bitmap_data =
            bmp.LockBits( new System.Drawing.Rectangle( 0, 0, bmp.Width, bmp.Height ),
                       System.Drawing.Imaging.ImageLockMode.ReadOnly,
                       pixel_format );

System.IntPtr pPixels = bitmap_data.Scan0;


pPixels is a pointer that points to raw pixel data.

As a test you can create a bitmap copy using pPixels and pixel_format:

Code: Select all

System.Drawing.Bitmap bmp_copy =
            new System.Drawing.Bitmap( bmp.Width, bmp.Height, bitmap_data.Stride, pixel_format, bitmap_data.Scan0);
         bmp_copy.Save(@"C:\1.bmp");

bmp.UnlockBits(bitmap_data);
Best regards, Artem A. Razin,
F-IN-BOX support
Ask your question here: http://www.f-in-box.com/support.html


Return to “.NET Edition”

Who is online

Users browsing this forum: No registered users and 14 guests

cron