473,569 Members | 2,466 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Create a temp copy of a bitmap

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.FromIm age(MyPpic.Imag e)
Dim pen As New Pen(Color.Gray)
g.DrawRectangle (pen, 0, 0, MyPpic.Image.Wi dth - 1,
MyPpic.Image.He ight - 1) ' draw border
Clipboard.SetDa taObject(MyPpic .Image)
''''
Nov 21 '05 #1
2 2524
"John" <Jo**@discussio ns.microsoft.co m> schrieb:
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.FromIm age(MyPpic.Imag e)
Dim pen As New Pen(Color.Gray)
g.DrawRectangle (pen, 0, 0, MyPpic.Image.Wi dth - 1,
MyPpic.Image.He ight - 1) ' draw border
Clipboard.SetDa taObject(MyPpic .Image)
''''


You will have to create a new 'Bitmap' object, get a 'Graphics' object and
draw the original image and the border onto the temporary bitmap.

\\\
Dim b As New Bitmap(100, 100, ...)
Dim g As Graphics = Graphics.FromIm age(b)
g.DrawImage(x, ...)
g.DrawRectangle (...)
g.Dispose()
Clipboard.SetDa taObject(b)
///

--
M S Herfried K. Wagner
M V P <URL:http://dotnet.mvps.org/>
V B <URL:http://classicvb.org/petition/>

Nov 21 '05 #2

"John" <Jo**@discussio ns.microsoft.co m> wrote in message
news:B9******** *************** ***********@mic rosoft.com...
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.FromIm age(MyPpic.Imag e)
Dim pen As New Pen(Color.Gray)
g.DrawRectangle (pen, 0, 0, MyPpic.Image.Wi dth - 1,
MyPpic.Image.He ight - 1) ' draw border
Clipboard.SetDa taObject(MyPpic .Image)
''''


Clone the graphics object first, as follows:

Dim img As Image = MypPic.Image.Cl one()
Dim g As Graphics = Graphics.FromIm age(img)
Dim pen As Pen = New Pen(Color.Blue)
g.DrawRectangle (pen, 0, 0, img.Width - 1, img.Height - 1)
Clipboard.SetDa taObject(img)
HTH,
Mythran

Nov 21 '05 #3

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

Similar topics

2
3112
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
7
8835
by: dog | last post by:
I've seen plenty of articles on this topic but none of them have been able to solve my problem. I am working with an Access 97 database on an NT4.0 machine, which has many Access reports. I want my users to be able to select a report, click on a command button on a form, which will then automatically create the report as a pdf file and...
2
11253
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...
7
11608
by: lgbjr | last post by:
Hello All, I¡¯m using a context menu associated with some pictureboxes to provide copy/paste functionality. Copying the image to the clipboard was easy. But pasting an image from the clipboard is proving to be more difficult. These pictureboxes are bound to an AccessDB. If the user wants to add an image, they select an image using an...
6
4736
by: Rich | last post by:
Hello, I want to simulate the dynamic thumbnail display of Windows Explorer (winxp) on a form or pannel container. If I place a picture box on my container form/pannel and dimension it to the size of a thumbnail and set the sizemode to Stretch -- I get one thumbnail. I want to retrieve all the picture files (jpg, bmp) in a directory into...
8
2563
by: Paw | last post by:
Greetings. I use asp. what I need is is when a visitor comes to the site, I need it to check the host name. if "www.hometowndigest.com" is the host, then check a folder named "something" and if the folder does not exsist, create folder "www" and then copy folder "temp" and its contents. If the folder "www" is there, look in it, check to...
23
7371
by: sandy | last post by:
I need (okay, I want) to make a dynamic array of my class 'Directory', within my class Directory (Can you already smell disaster?) Each Directory can have subdirectories so I thought to put these in an array. The application compiles but aborts without giving me any useful information. What I suspect is happening is infinite recursion....
5
4164
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;
3
3714
by: radu | last post by:
i need a bit of help with few lines of code. 1. i have integer array a = numbers from 0 to 256 2. i have to create a 256 colours bitmap of 500x500 pixels, asign colours as matrix a. ex. bitmap at pixel at row 3 col 5 = colour number is a and save it to disk as a 256 colour bitmap without any compresion as c:\a.bmp. no interface. i have...
0
7703
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, 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...
0
7618
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...
0
8132
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...
1
7678
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...
0
7982
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...
0
6286
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...
0
5222
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...
0
3656
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...
0
3644
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?

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.