473,499 Members | 1,568 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

How to find out a color from .bin file

13 New Member
Hello people

am working on bmp files and i am given a task of detecting the color form the bmp file....so i converted the bmp file in hex file that is .bin file and now it is becoming a pain to serch for the color red in the bin file....could anyone plz suggest me a way as to how to read the bin file and how to serch for the red color in the file...
hope to find some solution...
Nov 13 '06 #1
6 1974
sivadhas2006
142 New Member
Hi,

BMP files are written with respect to the header information.
If you know the header of the bmp file, you can easily get the information of color. i.e., pixel value.

Try the links.

http://web.uccs.edu/wbahn/ECE1021/ST...fileformat.htm

http://local.wasp.uwa.edu.au/~pbourke/dataformats/bmp/



Regards,
M.Sivadhas.
Nov 13 '06 #2
ranjitneo
13 New Member
Thank you for the response....but what i have worked on is that i have removed the header file in the .bin file...what i mean to say is that the .bin file that i am workin on does not have the header.(coz i have removed it...)..now i want to search this resulting bin file and find out the color...that is red... any code to locate the color red will be very much appreciated.....

Regrds
Ranjit
Nov 13 '06 #3
sivadhas2006
142 New Member
Hi,

Can I know what is the format the data stored in the bin file.
i.e., RGBA, ARGB or just RGB.

R Stands for Red,
G Stands for Green,
B Stands for Blue and
A Stands for Alpha.

Regards,
M.Sivadhas.
Nov 14 '06 #4
ranjitneo
13 New Member
hi

It is in RGB format.....

Thanks a lot ...
Regards
Ranjit
Nov 14 '06 #5
baburk
111 New Member
Hai ranjitneo

The color is stored as BGR If it is a 24 bit and 4th byte is reserved.

B = Blue
G = Green
R = Red


.
Nov 15 '06 #6
macklin01
145 New Member
Well, you could just read the file using any one of the bitmap libraries out there, and directly access the pixels.

If you want info on the BMP file format, I'd look here: http://www.fortunecity.com/skyscrape.../bmpffrmt.html

It will tell you how many bytes you need to strip out until you reach the first amount of data. If it's not a 24-bit or 32-bit image, however, it will be a bit more difficult. (color tables and/or bit masks, etc.)

That reference was particularly helpful to me for writing my own bitmap library.
(EasyBMP)

If you choose to use that, it's as follows:
Expand|Select|Wrap|Line Numbers
  1. ...
  2. #include "EasyBMP.h"
  3. ..
  4.  
  5. // declare and read an image
  6.  
  7. BMP Image;
  8. Image.ReadFromFile( "my_image.bmp" );
  9.  
  10. // get info on pixel (3,12)
  11.  
  12. cout << "Pixel (3,12) : (" 
  13.        << Image(3,12)->Red << " , " 
  14.        << Image(3,12)->Green << " , " 
  15.        << Image(3,12)->Blue << ")" << endl;
  16.  
  17. // change pixel (4,3) to the color (255,0,128):
  18.  
  19. Pixel(4,3)->Red = 255;
  20. Pixel(4,3)->Green = 0;
  21. Pixel(4,3)->Blue = 128;
  22.  
  23. // save the modified image
  24.  
  25. Image.WriteToFile( "modified_image.bmp" );
  26.  
That's it. :) -- Paul
Nov 15 '06 #7

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

Similar topics

10
33655
by: hokieghal99 | last post by:
import os, string print " " setpath = raw_input("Enter the path: ") def find_replace(setpath): for root, dirs, files in os.walk(setpath): fname = files for fname in files: find =...
7
4809
by: Bart Nessux | last post by:
x = str.find(temp, '120.50') I am looking for '120.50' '120.51' '122.78' etc. How can I do this with just one str.find... I can use re if I must, but I'd like to avoid it if possible.
6
1760
by: Peter Hansen | last post by:
Greetings. Im trying to write a program that can be run from the command line. If I want to search for example after a file with the ending .pdf, I should be able to write in the command line:...
1
3704
by: Xah Lee | last post by:
suppose you want to do find & replace of string of all files in a directory. here's the code: ©# -*- coding: utf-8 -*- ©# Python © ©import os,sys © ©mydir= '/Users/t/web'
1
4052
by: Pierre-Yves | last post by:
Hello, I have to loop recursively in directories to build a tree. Based on the directory name, I know I can skip some (i.e: the BACKUP ones) to improve the performances that are currently very...
1
7577
by: Dan Jones | last post by:
I'm writing a script to process a directory tree of images.  In each directory, I need to process each image and generate an HTML file listing all of the images and links to the subdirectories....
1
13647
by: Harsha | last post by:
I have been working on VB, ASP for quite a long time. Very Recently ( From past 1 month) I am managing a VC++ project. I am trying to use the code which i downloaded from the internet to find the...
1
3935
by: mirandacascade | last post by:
I do not understand how to use the find() method in ElementTree. The file 'sample.xml' is: <?xml version="1.0"?> <SampleRoot> <Header> <Product>FindMystery</Product> </Header>...
5
11004
by: Tim Eliot | last post by:
Just wondering if anyone has hit the following issue and how you might have sorted it out. I am using the command: DoCmd.TransferText acExportMerge, , stDataSource, stFileName, True after...
1
2737
by: Xiangliang Meng | last post by:
Hi, all. Recently, I find there is a way in our project to maintain a global set in many files by using preprocessing directives. I'm wondering if we could find a better method for this. Many...
0
7009
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
7223
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...
1
6899
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
7390
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
0
5475
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...
1
4919
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new...
0
4602
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and...
0
3094
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
0
1427
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated ...

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.