473,383 Members | 1,859 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,383 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 5633
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:
In our work, we often need to import Excel data into databases (such as MySQL, SQL Server, Oracle) for data analysis and processing. Usually, we use database tools like Navicat or the Excel import...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
0
by: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
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
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
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...

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.