473,326 Members | 2,099 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,326 software developers and data experts.

how to use 8 bit values (black and white picture) to create a BMP picture

Hi,

I am using Visual Basics 2005 and I am reading 8 bit values (pixel) from a CMOS camera (385 * 288 pixels) throught a serial port and need help in creating an image out of these values in BMP format

Thank You

Pradeepan Arunthavarajah
Apr 9 '07 #1
7 3456
Killer42
8,435 Expert 8TB
I am using Visual Basics 2005 and I am reading 8 bit values (pixel) from a CMOS camera (385 * 288 pixels) throught a serial port and need help in creating an image out of these values in BMP format
Are these grayscale values?
Apr 10 '07 #2
Are these grayscale values?
yes these are grayscale values (8 bit) your help will be appreciated
Apr 12 '07 #3
Killer42
8,435 Expert 8TB
yes these are grayscale values (8 bit) your help will be appreciated
I certainly won't claim this is the best way, but perhaps the simplest would be to create a picturebox, then just loop through the values and use Pset (or whatever the equivalent is in VB.Net) to draw each pixel. Then save the picture from the picturebox.

In VB6, I would use something like this to set the colour of each point.
Expand|Select|Wrap|Line Numbers
  1. ' Assumed values...
  2. ' X = X coordinate
  3. ' Y = Y coordinate
  4. ' InputvALUE = grayscale value from white (0) to black (255)
  5. InputColour = 255 - InputValue
  6. OutputColour = RGB(InputColour, InputColour, InputColour)
  7. Picture1.Pset (X, Y), OutputColour
Apr 13 '07 #4
thanks for ur help

however i'm getting the values from the com port and since it's coming thru the port one character (byte) at a time how do I convert it to ASCII meaning getting the DEC (decimal) values instead of the character values. Using these decimal values which represents 8 bits (0-255) each will be used to create a picture.

Also, I need clarifying in what Picture1.Pset command is because I will just need the picture to be displayed in PictureBox and saved as an image in BMP format

thanks in advance
Apr 23 '07 #5
Killer42
8,435 Expert 8TB
thanks for ur help

however i'm getting the values from the com port and since it's coming thru the port one character (byte) at a time how do I convert it to ASCII meaning getting the DEC (decimal) values instead of the character values. Using these decimal values which represents 8 bits (0-255) each will be used to create a picture.
:confused:

What you are getting through the port will be a stream of bytes. In other words, numeric values in the range 0-255. These numbers can represent anything you want them to - you can treat them as an ASCII character, a grayscale value, or whatever.

There are a number of functions in VB6 to convert between different formats such as ASC(string character to ASCII value) or CHR(ASCII value to string character), HEX(decimal to hexadecimal), VAL(string of numeric digits to numeric value) and so on.

If each value represents a "picture" then it seems as though one of the following must be true...
  1. You're not making yourself clear (at least to me).
  2. They are very simple pictures, if they can be represented by a single byte.
  3. They are simply a kind of index number indicating a selection from a collection of pictures that you already have available.

Also, I need clarifying in what Picture1.Pset command is because I will just need the picture to be displayed in PictureBox and saved as an image in BMP format
The PSET method of the picturebox sets the specified point to the specified colour. In other words, it draws a dot. I was using it to take each grayscale value and draw a dot of the corresponding shade of gray. If this worked as planned, eventually you would drawn your image, one dot at a time. This is basically what a bitmap is - a bunch of numbers representing the colour (and/or brightness) of each dot in an image.
Apr 24 '07 #6
:confused:

What you are getting through the port will be a stream of bytes. In other words, numeric values in the range 0-255. These numbers can represent anything you want them to - you can treat them as an ASCII character, a grayscale value, or whatever.

There are a number of functions in VB6 to convert between different formats such as ASC(string character to ASCII value) or CHR(ASCII value to string character), HEX(decimal to hexadecimal), VAL(string of numeric digits to numeric value) and so on.

If each value represents a "picture" then it seems as though one of the following must be true...
  1. You're not making yourself clear (at least to me).
  2. They are very simple pictures, if they can be represented by a single byte.
  3. They are simply a kind of index number indicating a selection from a collection of pictures that you already have available.

The PSET method of the picturebox sets the specified point to the specified colour. In other words, it draws a dot. I was using it to take each grayscale value and draw a dot of the corresponding shade of gray. If this worked as planned, eventually you would drawn your image, one dot at a time. This is basically what a bitmap is - a bunch of numbers representing the colour (and/or brightness) of each dot in an image.
yes it will be stream of bytes and each byte will represent a pixel value
and what is PSet equivalence in visual Basic 2005
thanks in advance
Apr 25 '07 #7
Killer42
8,435 Expert 8TB
yes it will be stream of bytes and each byte will represent a pixel value and what is PSet equivalence in visual Basic 2005
I don't know. You'll just have to look up the documentation, I suppose.

If you can't find the equivalent command, try searching for Pset. If it's obsolete, the information about upgrading should tell you what replaced it.
Apr 25 '07 #8

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

Similar topics

3
by: Stijn Goris | last post by:
Hi all, I want to make a coloured picture black and white when a user moves its mouse pointer over it. I just don't want to store a coloured an black and white (grayscaled) version on the...
12
by: Penna Elabi | last post by:
How do I create a style sheet with black background and white text?
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...
4
by: Henrique Berenguel | last post by:
Hello folks. I have a DataGrid in a Web Form. I´d like to show numeric columns in Money format US$ 10,000.98. However, when I fill the DataGrid from a SqlCommand, it fill in the DataGrid like this:...
4
by: Jim in Arizona | last post by:
This doesn't make any sense to me. I'm hoping some SQL guru out there knows the answer. I'm making a help desk type database system. There's only two tables, one called TTickets and the other...
5
by: kaosyeti | last post by:
how can i get my report to print all in black when i have a control with conditional formatting to change the font color about 10% of the time it shows up. i've been trying to find a way to format...
0
by: schoultzy | last post by:
Hello Everyone, I have been trying to figure this one out for two days now. I have created a DataGridView which is populated by an ObjectDataSource. My problem occurs when I attempt to use the...
0
by: paruntha | last post by:
Hi, I am using Visual Basics 2005 and I am reading 8 bit values (pixel) from a CMOS camera (385 * 288 pixels) throught a serial port and need help in creating an image out of these values in BMP...
14
kadghar
by: kadghar | last post by:
Picture this: There are n guys, where n can be any number. This n guys are in a line so they can't see anyone behind them, but they can see everyone in front of them. The bad guys put a hat on...
9
by: George | last post by:
C with 2 sprained hands. I would nlike to emulate the t4 encoding scheme using the following graphic: * * * * * * ***** o O o o
0
by: DolphinDB | last post by:
Tired of spending countless mintues downsampling your data? Look no further! In this article, you’ll learn how to efficiently downsample 6.48 billion high-frequency records to 61 million...
1
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
0
by: Vimpel783 | last post by:
Hello! Guys, I found this code on the Internet, but I need to modify it a little. It works well, the problem is this: Data is sent from only one cell, in this case B5, but it is necessary that data...
0
by: jfyes | last post by:
As a hardware engineer, after seeing that CEIWEI recently released a new tool for Modbus RTU Over TCP/UDP filtering and monitoring, I actively went to its official website to take a look. It turned...
0
by: ArrayDB | last post by:
The error message I've encountered is; ERROR:root:Error generating model response: exception: access violation writing 0x0000000000005140, which seems to be indicative of an access violation...
1
by: PapaRatzi | last post by:
Hello, I am teaching myself MS Access forms design and Visual Basic. I've created a table to capture a list of Top 30 singles and forms to capture new entries. The final step is a form (unbound)...
1
by: CloudSolutions | last post by:
Introduction: For many beginners and individual users, requiring a credit card and email registration may pose a barrier when starting to use cloud servers. However, some cloud server providers now...
1
by: Defcon1945 | last post by:
I'm trying to learn Python using Pycharm but import shutil doesn't work
0
by: af34tf | last post by:
Hi Guys, I have a domain whose name is BytesLimited.com, and I want to sell it. Does anyone know about platforms that allow me to list my domain in auction for free. Thank you

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.