473,785 Members | 2,841 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

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 7489
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.a lgorithms or comp.os.<your_o s_here>.program mer.

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.********@com Acast.net> wrote in message
news:Dw******** ********@newsre ad1.dllstx09.us .to.verio.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.********@com Acast.net> wrote in message
news:Dw******** ********@newsre ad1.dllstx09.us .to.verio.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.********@com Acast.net> wrote in message
news:Dw******** ********@newsre ad1.dllstx09.us .to.verio.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.a lgorithms or comp.os.<your_o s_here>.program mer.


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.********@com Acast.net> wrote in message
news:Dw******** ********@newsre ad1.dllstx09.us .to.verio.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_o s_here>.program mer.

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.mi t.edu> wrote in message
news:10******** *************** ***@posting.goo gle.com...
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

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

Similar topics

5
4861
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 System.Drawing.Bitmap from that value? Regards, Steve
2
11263
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 the final line is drawn. How to avoid the series of lines being generated during mouse move event? How to get the rubberband effect when the user moves the mouse? I tried using the ControlPaint.Reversible line but this does not help
2
3707
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 Bitmap(Width,Height,PixelFormat.Format24bppRgb); i have a bitmapdata class and then lock the bits like this. bitmapData = bitmap.LockBits(bounds, ImageLockMode.ReadWrite, PixelFormat.Format24bppRgb);
3
31111
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 takes two minutes to complete. I am using the Panel's Paint event to call my drawing method, which accepts PaintEventArgs as a parameter. The problem is that every time the Window is moved or hidden, it needs to be repainted, which takes a long time...
3
417
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, EmfType.EmfOnly); grph.ReleaseHdc(ipHDC); grph.Dispose(); grph = Graphics.FromImage(mf); grph.DrawRectangle(aPen, 10, 10, 100, 120); grph.Dispose();
5
7377
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 after a while). Can somebody please tell me what I'm doing wrong? Here is a sample: Public Shared Function CreateBitmapFromArray( _ ByVal width As Integer, _ ByVal height As Integer, _ ByVal pixelFormat As Drawing.Imaging.PixelFormat, _
2
8377
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 Form at runtime. 3. Then adding several controls like Button, RadioButton,CheckBox etc to it. 4. Now i want to create bitmap with all controls showing on it which are added to this form.
0
2615
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
9480
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 effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
0
10330
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
1
10093
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 Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
0
9952
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 protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
0
8976
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, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
1
7500
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 presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
6740
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 then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
1
4053
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 we have to send another system
3
2880
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

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.