473,461 Members | 1,917 Online
Bytes | Software Development & Data Engineering Community
Create Post

Home Posts Topics Members FAQ

Merging images together

Hi all,

I have two images that I would like to merge together similar to a
watermark (one becomes semi-transparent).

Is there a way to do this in vb.net?

Thanks.

Oct 17 '07 #1
3 4629
On Oct 17, 7:06 am, toby.k.w...@googlemail.com wrote:
Hi all,

I have two images that I would like to merge together similar to a
watermark (one becomes semi-transparent).

Is there a way to do this in vb.net?

Thanks.
Off the top of my head:

1) Create a new bitmap object that represents the watermark image.
2) Loop through the bitmap's pixel and use SetColor and
Color.FromArgb() to set the alpha level of the pixel
3) Load the bitmap as normal.

Thanks,

Seth Rowe

Oct 17 '07 #2
Seth,

Thanks for your reply. I had tried this but it is really slow, and
wondered if there was a control or another way of doing this.

The code I have for your example is:

Dim clr As Color
For py As Integer = 0 To bm.Height - 1
For px As Integer = 0 To bm.Width - 1
clr = bm.GetPixel(px, py)
If clr <Color.White Then
bm.SetPixel(px, py, Color.FromArgb(ALPHA, clr.R, clr.G,
clr.B))
End If
Next px
Next py

' Set the watermark's transparent color.
bm.MakeTransparent(bm.GetPixel(0, 0))

' Copy onto the result image.
Dim gr As Graphics = Graphics.FromImage(PictureBox1.Image)
gr.DrawImage(bm, 0, 0)

Is there any way to speed this up?

Oct 18 '07 #3
On Oct 18, 7:58 am, toby.k.w...@googlemail.com wrote:
Seth,

Thanks for your reply. I had tried this but it is really slow, and
wondered if there was a control or another way of doing this.

The code I have for your example is:

Dim clr As Color
For py As Integer = 0 To bm.Height - 1
For px As Integer = 0 To bm.Width - 1
clr = bm.GetPixel(px, py)
If clr <Color.White Then
bm.SetPixel(px, py, Color.FromArgb(ALPHA, clr.R, clr.G,
clr.B))
End If
Next px
Next py

' Set the watermark's transparent color.
bm.MakeTransparent(bm.GetPixel(0, 0))

' Copy onto the result image.
Dim gr As Graphics = Graphics.FromImage(PictureBox1.Image)
gr.DrawImage(bm, 0, 0)

Is there any way to speed this up?
I'm not to sure about how to speed up your code. You may want to post
the code in the microsoft.public.dotnet.framework.drawing newsgroups,
as they will most likely be able to help you more. Also, you may see
if you can get the source for Paint .Net, it's a terrific program that
features variable transparency layers and I believe it's open source.
Taking a look at their algorithm might give you some ideas.

Thanks,

Seth Rowe

Oct 18 '07 #4

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

Similar topics

2
by: Nikhil Prashar | last post by:
I'm trying to merge two XML files that have the same structure but not necessarily the same nodes in the same order. I've tried opening the files as datasets and using the DataSet.Merge() function,...
3
by: Damian Arntzen | last post by:
I'm a beginner to moderate programmer who's fiddling around with automating Excel, in particular after being able to have the user fill out a form and it then generate the workbook. I can't quite...
2
by: Dan Cooper | last post by:
I've got two datasets, each containing a single data table. dstDataSetA.Tables("TableA") dstDataSetB.Tables("TableB") I want to merge them together and delete any non-matching rows. ...
0
by: inerarts | last post by:
Hi, I am looking simple application that can merge few images (same images, same size, different compression) together, by simple counting average of every pixel lightness. Thanks in advance.
0
by: Jack | last post by:
This is probably trivial, but I'm unable to find the answer. In vb.net 2005, if I'm merging 2 toolstrips together using ToolStripManager.Merge, how do I control the order of the merged buttons?...
2
by: timlitw | last post by:
A while back I researched and wrote a script that uses gd to make merge an arrow on a compass to show wind direction, and another on a speedometer to show wind speed, now I'd like to enhance these...
4
by: hunter1978 | last post by:
Hi, I hope somebody can help me? I've got a macro that pulls data from an Excel sheet into a table. Everything works okay but I need some way of merging the data in two columns together so that...
8
by: babyangel43 | last post by:
Hello, I have a query set up in Access. I run it monthly, changing "date of test". I would like this query to be merged with a Word document so that the cover letter is created in Word, the fields...
1
by: adamrace | last post by:
Hi, I've got two excel files, one has a list of products and their current prices and they all have a product ID, I have another file with a list of price's that need updating. I was wondering...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
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...
1
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...
0
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...
0
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,...
0
isladogs
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...
0
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...

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.