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. -
CDC* pDC = GetDC();
-
CDC memDC;
-
CBitmap newbmp;
-
CImage img;
-
CBrush brush;
-
brush.CreateSolidBrush(RGB(0, 0, 255));
-
pDC->SelectObject(&brush);
-
memDC.CreateCompatibleDC(pDC);
-
btmap.CreateCompatibleBitmap(&memDC, 300, 300);
-
pDC->Rectangle(10, 10, 80, 80);
-
pDC->Ellipse(60,60,220,220);
-
memDC.SelectObject(&newbmp);
-
memDC.BitBlt(0,0,300,300,pDC,0,0,SRCCOPY);
-
CString loc("C:\\atest.bmp");
-
LPCTSTR bmp = (LPCTSTR)loc;
-
img.Attach(newbmp);
-
img.Save(bmp,Gdiplus::ImageFormatBMP);
-
ReleaseDC(pDC);
-
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
1 5824 Banfa 9,065
Recognized Expert Moderator Expert
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.
Sign in to post your reply or Sign up for a free account.
Similar topics |
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 System.Drawing.Bitmap
|
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)
{
Graphics g;
g = pictureBox1.CreateGraphics();
g.FillRectangle(Brushes.White,0,0,160,160);
|
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
|
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 GraphicsPath along
with it.
How do I save it all in a single file? Or how do I "glue" graphicspath to
bitmap so they save together?
thanks,
|
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...
| |
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 it without
affecting the bitmap on the screen. Any suggestions? Thanks
'''''
Dim g As Graphics = Graphics.FromImage(MyPpic.Image)
Dim pen As New Pen(Color.Gray)
g.DrawRectangle(pen, 0, 0, MyPpic.Image.Width - 1,
|
by: Lee |
last post by:
I have the following code
using System;
using System.Windows.Forms;
using System.Drawing;
using System.Collections;
namespace FINN
{
|
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 Bitmap
public Bitmap MakeImage(string Text, SizeF Sf)
{
int width = (int)(Sf.Width)+2;
|
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, fGetPerformanceGrade(SalesPersonID as Long) as String to
retrieve that salesperson's grade (e.g. A+, A, A-, B+, B... D). Also one
other function, fGetMonthlySales(SalesPersonID as Long) as String to get
their sales figure, e.g. "$87K".
I want web visitors to be able to click...
|
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, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look !
Part I. Meaning of...
|
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,...
| |
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...
|
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,...
|
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...
|
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...
|
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();...
|
by: TSSRALBI |
last post by:
Hello
I'm a network technician in training and I need your help.
I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs.
The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols.
I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
| |
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
| |