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

Create Bitmap Draw on it and save it

Hi

Please tell me how to create a bitmap. Draw on it and how to save that bitmap to a bmp file.

I done following : on a button click event.

Expand|Select|Wrap|Line Numbers
  1.         CDC* pDC = GetDC();
  2.     CDC memDC;
  3.     CBitmap newbmp;
  4.     CImage img;    
  5.     CBrush brush;
  6.     brush.CreateSolidBrush(RGB(0, 0, 255));
  7.     pDC->SelectObject(&brush);
  8.     memDC.CreateCompatibleDC(pDC);
  9.     btmap.CreateCompatibleBitmap(&memDC, 300, 300);
  10.     pDC->Rectangle(10, 10, 80, 80);
  11.     pDC->Ellipse(60,60,220,220);
  12.     memDC.SelectObject(&newbmp);    
  13.     memDC.BitBlt(0,0,300,300,pDC,0,0,SRCCOPY);
  14.     CString loc("C:\\atest.bmp");
  15.     LPCTSTR bmp = (LPCTSTR)loc;
  16.     img.Attach(newbmp);
  17.     img.Save(bmp,Gdiplus::ImageFormatBMP);
  18.     ReleaseDC(pDC);
  19.  
But all do just get the window details and save it. If there a window above that it will also draw that.

Every thing we draw with pDC come on the screen. Such that is there any way to draw to CDC of bitmap (similar to CDC pDC = GetDC();). And when we save it then only what we draw on that CDC should be saved, nothing more.

Please reply immediatly ..
Thanks in advance
Aqeek
Feb 25 '08 #1
1 5635
Banfa
9,065 Expert Mod 8TB
Instead of pDC->Rectangle call memDC->Rectangle, but only after you have selected the bitmap into the memDC. Same for Eclipse. Don't call memDC.BitBlt.
Feb 26 '08 #2

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

Similar topics

2
by: Programmer | last post by:
Hi all Here is my problem I want to create an image so i can pass it on an object to put it as watermark in my pdf report Here is what i have write so far Dim objBitmap As...
6
by: charsh | last post by:
Hi, I using the code below to draw a text in a pictureBox1. //Start--------------------------------------------------------------- private void button1_Click(object sender, System.EventArgs e)...
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...
1
by: jay | last post by:
I have a bitmap and a graphicspath object. I draw pixels on m_Bitmap and I'm drawing text using m_Graphics GraphicsPath object. However, saving my work with m_Bitmap.Save doesn't save...
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...
2
by: John | last post by:
The following 4 lines add a border to a bitmap and save it into clipboard, however it also add a border to the bitmap on the screen. I want to create a temp copy of the bitmap and add a border to...
12
by: Lee | last post by:
I have the following code using System; using System.Windows.Forms; using System.Drawing; using System.Collections; namespace FINN {
5
by: WT | last post by:
I am trying to crete a gif file with transparent backcolor on the fly but it seems that GDI refuses to do this. I am using samples from Bob Powell but it doesn't seem to work. First create a...
11
by: Mark B | last post by:
I want to display a pre-designed graphical 'performance badge' on certain webpages (round, about 2cm diameter) next to a salesperson's details. I have a function,...
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: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
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
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
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,...
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.