473,796 Members | 2,875 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
11 7490
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.l earn.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
4862
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
7378
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
2616
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
9527
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
10453
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...
0
10223
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 tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
1
10172
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
10003
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
5573
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
4115
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
2
3730
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
3
2924
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.