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

How to create a bitmap?

Hi,

I have a huge problem. I have a data file which looks something like
this -:
..1 .5 .9 -1 .2 .5 ......
..2 .9 .1 .4 .3 -1 ......
..2 .4 .5 .7 .6 .2 ......
........
........

Now I have to create a bitmap out of this using C++ and I really dont
know how to do it? Could someone please tell me a way to go about this
or atleast point me in the right direction?

Thanks,
Prashant
Jul 22 '05 #1
11 7431
Prashant wrote:
I have a huge problem. I have a data file which looks something like
this -:
.1 .5 .9 -1 .2 .5 ......
.2 .9 .1 .4 .3 -1 ......
.2 .4 .5 .7 .6 .2 ......
.......
.......

Now I have to create a bitmap out of this using C++ and I really dont
know how to do it? Could someone please tell me a way to go about this
or atleast point me in the right direction?


What's a bitmap? Depending on your answer, you should go to either
comp.graphics.algorithms or comp.os.<your_os_here>.programmer.

C++ _language_ (the subject of this newsgroup) does not define any
"bitmaps". There are bit fields and bitsets, there are maps, but no
bitmaps, sorry.

Victor
Jul 22 '05 #2
"Victor Bazarov" <v.********@comAcast.net> wrote in message
news:Dw****************@newsread1.dllstx09.us.to.v erio.net...
Prashant wrote:
I have a huge problem. I have a data file which looks something like
this -:
.1 .5 .9 -1 .2 .5 ......
.2 .9 .1 .4 .3 -1 ......
.2 .4 .5 .7 .6 .2 ......
.......
.......

Now I have to create a bitmap out of this using C++ and I really dont
know how to do it? Could someone please tell me a way to go about this
or atleast point me in the right direction?


What's a bitmap?


std::map<bit>

....

I think. ^_^

--
Unforgiven

Jul 22 '05 #3
Unforgiven wrote:
"Victor Bazarov" <v.********@comAcast.net> wrote in message
news:Dw****************@newsread1.dllstx09.us.to.v erio.net...
Prashant wrote:
I have a huge problem. I have a data file which looks something like
this -:
.1 .5 .9 -1 .2 .5 ......
.2 .9 .1 .4 .3 -1 ......
.2 .4 .5 .7 .6 .2 ......
.......
.......

Now I have to create a bitmap out of this using C++ and I really dont
know how to do it? Could someone please tell me a way to go about this
or atleast point me in the right direction?

What's a bitmap?

std::map<bit>


error: 'bit' undefined
...

I think. ^_^


You _think_? Lucky bastard! I write programs.
Jul 22 '05 #4

"Victor Bazarov" <v.********@comAcast.net> wrote in message
news:Dw****************@newsread1.dllstx09.us.to.v erio.net...
Prashant wrote:
I have a huge problem. I have a data file which looks something like
this -:
.1 .5 .9 -1 .2 .5 ......
.2 .9 .1 .4 .3 -1 ......
.2 .4 .5 .7 .6 .2 ......
.......
.......

Now I have to create a bitmap out of this using C++ and I really dont
know how to do it? Could someone please tell me a way to go about this
or atleast point me in the right direction?


What's a bitmap? Depending on your answer, you should go to either
comp.graphics.algorithms or comp.os.<your_os_here>.programmer.


Howcome no one ever asks "what's reference counting" or similiar questions,
and follow them with: "the c++ does not know what reference counting is.." ?
:)

int width = ...;
int height = ...;
float* bitmap = new float[width * height];

Then write the data you want into the "bitmap", or if you want to keep the
width and height, you might want to store them into object, so create a
class for this:

class bitmap
{
protected:
int m_width;
int m_height;
float* m_image;
public:
bitmap(int width, int height);
// ...
};

bitmap object(640,480);
// ...

Jul 22 '05 #5
assaarpa wrote:
"Victor Bazarov" <v.********@comAcast.net> wrote in message
news:Dw****************@newsread1.dllstx09.us.to.v erio.net...
Prashant wrote:
I have a huge problem. I have a data file which looks something like
this -:
.1 .5 .9 -1 .2 .5 ......
.2 .9 .1 .4 .3 -1 ......
.2 .4 .5 .7 .6 .2 ......
.......
.......

Now I have to create a bitmap out of this using C++ and I really dont
know how to do it? Could someone please tell me a way to go about this
or atleast point me in the right direction?
What's a bitmap? Depending on your answer, you should go to either
comp.graphics.algorithms or comp.os.<your_os_here>.programmer.

Howcome no one ever asks "what's reference counting" or similiar questions,
and follow them with: "the c++ does not know what reference counting is.." ?
:)


Reference counting is covered in the FAQ, if you want to know.

int width = ...;
int height = ...;
float* bitmap = new float[width * height];
How is this a _bitmap_? All you showed is how to create a dynamic
array of floats. You can call the pointer "yo mama", but it's not
gonna give birth to your sister.

Then write the data you want into the "bitmap", or if you want to keep the
width and height, you might want to store them into object, so create a
class for this:

class bitmap
{
protected:
int m_width;
int m_height;
float* m_image;
public:
bitmap(int width, int height);
// ...
};

bitmap object(640,480);
// ...


So, after answering this OT question (and thus encouraging OT posts),
the next question you're going to get is "how do I put it on the
screen?" Are you prepared to go all the way? I am not. And neither
are many folks here.

V
Jul 22 '05 #6
> Reference counting is covered in the FAQ, if you want to know.

Sorry, the C++ doesn't know about FAQ or reference counting. ;-)
How is this a _bitmap_? All you showed is how to create a dynamic
array of floats.
How that is not a _bitmap_ ?

The de-facto convention to store 2D matrix is to use a linear array as
storage. This was a suggestion, if it does not fit the original poster's
criteria he can give more information and if it drifts too much away from
C++, I will re-evaluate the situation.
So, after answering this OT question (and thus encouraging OT posts),
the next question you're going to get is "how do I put it on the
screen?"
I gave C++ code for one (very common) way to store floating-point grayscale
bitmap in memory, that is not very platform specific question. He specificly
asked how to do this in C++, I answered how to do that in C++. If he wants
to "put the bitmap in to the screen", that requires platform specific
information and for that I will gladly redirect him.
Are you prepared to go all the way?
Sure, why not? I would put the floating-point bitmap "on the screen" using
DirectX 9.0c or OpenGL 1.5, depending on the platform and availability of
these libraries. If neither of these is option then I will re-evaluate the
approach depending on the available choises.
I am not.
Great, but then don't be so smug about it, because that was what prompted me
to 'help' the original poster in the first place. Stay professional if
that's what you expect the quality of the conversation to be.
And neither are many folks here.


My point wasn't to help with graphics programming per-se, that is off-topic
and I agree with that. C++ _language_ (the subject of this newsgroup) does
not define any "bitmaps", true, but if someone did ask: "what would be a
reasonable approach to store 2D matrix of floating-point values", you nor
many folks here wouldn't find a problem to give a beginner a kickstart into
the right direction, like I did with the very basic "bitmap" class. I don't
think the way I answered the question was graphics programming related in a
big way or that it was off-topic in a very distractive manner. Chill out,
maybe ignore me, I don't care but I definitely am not going to be your
puppet: I will use my own initiative to consider when I reply and who I
reply to and you are free to do the same.
Jul 22 '05 #7

"assaarpa" <re***********@fap.net> wrote in message
news:ck**********@phys-news1.kolumbus.fi...
Reference counting is covered in the FAQ, if you want to know.


Sorry, the C++ doesn't know about FAQ or reference counting. ;-)
How is this a _bitmap_? All you showed is how to create a dynamic
array of floats.


How that is not a _bitmap_ ?


Personally, I've never heard of a floating-point bitmap before. Every
bitmap I've ever worked with (and that's a lot) uses some form of integer or
combination of integers (such as three integer: R,G, and B). In any case,
I'd bet the farm (well, the back forty, anyway), that the OP wanted to know
how to create a specific type of bitmap (such as a CBitmap object in VC++ or
something similar), which is exactly what makes the query off-topic here.

I am curious as to the OP's data. Whatever is eventually used to actually
display that data as a bitmap (in the common graphical sense), some kind of
mapping function is going to be needed to determine what those values are
intended to represent. For example, is the -1 supposed to mean black (no
color), or what? So he's really got two problems. First, how is the data
to be mapped to some kind of color scheme, and second, how to display those
colors. The first is a requirements or design decision on his part, the
second is simply off-topic here.

-Howard


Jul 22 '05 #8
> Now I have to create a bitmap out of this using C++ and I really dont
know how to do it? Could someone please tell me a way to go about this
or atleast point me in the right direction?

Thanks,
Prashant


It always amuses me how much text is wasted by childish
posters whining and crying about things being off topic,
not having anything to do with C++, etc rather than just
either ignoring the message entirely or posting something
that is actually constructive.

I will post something constructive. This file

http://www.duggar.org/portal/image_bmp.tar.gz

contains some bitmap writing code that I wrote. It is old
and rough so I make no promises as too it's quality,
readability, or portability. That said, it has worked for
me in the past and I would be willing to help you improve
or modify it.

Download it, see if you can understand/use it, and if you
need or want help feel free to email me directly.

Also, if fellow C++ coders have suggestions, bug reports,
or enhancements I'd appreciate your input. If it concerns
C++ issues I'm sure that it would be on topic to post it
here.

Finally, your question presented a matrix of float values.
You will need to decide how to convert those values to
color values. If you like I can help you with this as
well. I have written C++ code that mucks around with color
spaces (RGB8, sRGB, CIEXYZ, CIELAB, etc) that I would be
happy to share with you.

Keith
Jul 22 '05 #9

"Keith H Duggar" <du****@alum.mit.edu> wrote in message
news:10**************************@posting.google.c om...
Now I have to create a bitmap out of this using C++ and I really dont
know how to do it? Could someone please tell me a way to go about this
or atleast point me in the right direction?

Thanks,
Prashant


It always amuses me how much text is wasted by childish
posters whining and crying about things being off topic,
not having anything to do with C++, etc rather than just
either ignoring the message entirely or posting something
that is actually constructive.


Posting off-topic answers to off-topic questions simply encourages more
off-topic questions. That's why we discourage answering them here. This
forum has a purpose, and that purpose is to discuss the C++ language, as
defined by the standard. There are groups dedicated to graphics, specific
compilers, specific platfroms, etc., where such information is discussed.
What *might* be considered a constructive answer here would be to point the
OP to someplace where their question would be better answered. (Or send
your own answer to the OP directly, off-group, instead of posting it here
along with your flaming opinions.) Calling us names is not going to "shame"
us into changing the way this group works. I'm happy that we amuse you. I
hope calling us names has further amused you. Can we return to the topic of
the C++ language now?

-Howard
---"I'm not a brat! I'm NOT! I'm NOT! I'm NOT!"

Jul 22 '05 #10
Prashant wrote:
Hi,

I have a huge problem. I have a data file which looks something like
this -:
.1 .5 .9 -1 .2 .5 ......
.2 .9 .1 .4 .3 -1 ......
.2 .4 .5 .7 .6 .2 ......
.......
.......

Now I have to create a bitmap out of this using C++ and I really dont
know how to do it? Could someone please tell me a way to go about this
or atleast point me in the right direction?

Thanks,
Prashant


For your data, I believe that a graph would suffice better
than a bitmap. For advice on how to draw a graph, search
the web for libraries or consult newsgroups on graphics,
programming or your platform.

This data could be interpreted as a matrix of pixels, but
_you_ would have to decide on how to map the values to
pixel colors or shades of gray.

--
Thomas Matthews

C++ newsgroup welcome message:
http://www.slack.net/~shiva/welcome.txt
C++ Faq: http://www.parashift.com/c++-faq-lite
C Faq: http://www.eskimo.com/~scs/c-faq/top.html
alt.comp.lang.learn.c-c++ faq:
http://www.comeaucomputing.com/learn/faq/
Other sites:
http://www.josuttis.com -- C++ STL Library book
http://www.sgi.com/tech/stl -- Standard Template Library

Jul 22 '05 #11
> Personally, I've never heard of a floating-point bitmap before. Every

I have. Those are used all the time, personally I don't discriminate between
floating-point and integer pixelformats being relevant or not. For example
OpenEXR format is a HDR fileformat which supports 16-bit and 32-bit floating
point color and arbitrary data channels. Also, if you do GPU specific work
you will find out that grayscale or otherwise mono-channel floating-points
are used frequently, this is true for both OpenGL and DX 9.0c specific work.
It's not uncommon at all.
bitmap I've ever worked with (and that's a lot) uses some form of integer or combination of integers (such as three integer: R,G, and B). In any case,
Those are very common ones for the reason that most hardware for
workstations and Windows follow de-facto conventions so that they play the
ball with the standard API's like X and GDI. If you look into OpenGL 1.5 /
2.0 and DirectX 9.0c you might notice that in the recent years a lot of
formats have been standardized so that applications can do HDR imaging in
wider range of hardware with smaller investment in development times.
I'd bet the farm (well, the back forty, anyway), that the OP wanted to know how to create a specific type of bitmap (such as a CBitmap object in VC++ or something similar), which is exactly what makes the query off-topic here.
I'm sure he can ask the question and we can then turn him down if it is
off-topic, so far it has been on-topic. This bickering and second guessing
him has been more off-topic than his question.
I am curious as to the OP's data. Whatever is eventually used to actually
display that data as a bitmap (in the common graphical sense), some kind of mapping function is going to be needed to determine what those values are
intended to represent. For example, is the -1 supposed to mean black (no
color), or what? So he's really got two problems. First, how is the data
The input could be anything, it don't necessarily have to be color. I do
store normal maps, displacement and other data in bitmap objects. For
example in the case of displacement data I will only have one channel active
and I will tag it as "luminance", even though it is just some arbitrary
scalar data. This is a very common practise with vertex- and fragment
programming, the fragment program for example discriminates between
different channels using default names for them even if the program doesn't
ultimately write the channel into respective output fragment's channel. Big
deal.

I see he has a floating point matrix of data and wants to do SOMETHING with
it. So far he asked how to put it into bitmap, I am not sure if his problem
is converting the data from ascii to binary or what. He is a thinking human
being and will ask if he continues to have trouble and cannot sort it out
for himself.
to be mapped to some kind of color scheme, and second, how to display those colors. The first is a requirements or design decision on his part, the
second is simply off-topic here.


I don't see any question about displaying the data yet, so far it is
on-topic.
Jul 22 '05 #12

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

5
by: Steve Amey | last post by:
Hi all I have an ARGB value for a Colour (Eg. -65536. The value was retrieved by using the Color.ToArgb method), is there any way that I can create a System.Drawing.Image or a...
2
by: Anand Ganesh | last post by:
Hi All, In my application I am allowing the user to draw a line. But when the user clicks the start point and starts moving the mouse there is a series of line generated. When the mouse is up...
2
by: James Dean | last post by:
I create a bitmap like this. The width and height are got from the compressed file i am reading. The width and height are in pixels.....1bpp bitmap = new...
3
by: Bradford | last post by:
I have an Windows application that displays lots of different colored lines in a Panel by using the Graphics.DrawLine method. The location and length of each line comes from a database query that...
3
by: Richard Skopal | last post by:
In .NET Windows forms I can create a metafile using this code: Graphics grph = aControl.CreateGraphics(); IntPtr ipHDC = grph.GetHdc(); Metafile mf = new Metafile(aImgFilePath, ipHDC,...
5
by: Lance | last post by:
I need to create a Drawing.Bitmap from an array of integer values. My current technique creates a bitmap that eventually becomes corrupt (i.e., the bitmap's pixels change to a different color...
2
by: Melisa | last post by:
Hi, How can i create bitmap of a window form with all its child controls without showing this form? 1. I am trying to create bitmap image of a window form. 2. I am creating a new instance of...
0
by: news.microsoft.com | last post by:
Hi guys, This text looks long and complicate but it is not, and I really really need some help here. For the last 24hs I'm trying to resolve this issue (last night I dreamed
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: 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...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
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
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
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
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.