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

Possible bug in System.Drawing.Graphics when dealing with multipage TIFFs and transparency

Hello group,
My goal is to attach an image over another image.
Top image should be transparent so the back image is visible through the top
one.

Bellow is a test code in VB.NET. You need to create a form, a button
(Button1) and an Picture Box (picBox).
"watermark.jpg" is any jpg image, "beispiel.tif" is a multipage TIFF image
with the white background, which will turn to transparent.
The most important thing here is that the TIFF image should be a multipage
type (multiple images in a single *.TIF file).
You can download a multipage TIFF for testing from:
http://www.patent-inf.tu-ilmenau.de/...e/beispiel.tif

The bug(?) is:
In the code bellow the line:
imgTop.SelectActiveFrame(System.Drawing.Imaging.Fr ameDimension.Page, 4)
is doing the same as
imgTop.SelectActiveFrame(System.Drawing.Imaging.Fr ameDimension.Page, 0)
That means, it does not select the page 4. It selects the first page
instead, no matter we specified "4".

My guess is that this odd behaviour has something to do with the
transparency of the image, because when the line:
imgTop.MakeTransparent(Color.White) is commented, the thing works, the
desired page is selected, but there is no transparency and the background
image is not visible.
The source code:
''''''''''''''''''''''''''''''''''''''
Private Sub Button1_Click(ByVal sender As System.Object, _
ByVal e As System.EventArgs) Handles Button1.Click
Dim imgBack As New Bitmap("d:\temp\watermark.jpg")
Dim imgTop As Bitmap = New Bitmap("d:\temp\beispiel.tif")
Dim g As Graphics = Graphics.FromImage(imgBack)

Dim rect As New Rectangle(0, 0, imgBack.Width, imgBack.Height)
imgTop.SelectActiveFrame(System.Drawing.Imaging.Fr ameDimension.Page,4)
imgTop.MakeTransparent(Color.White)
g.DrawImage(imgTop, rect, 0, 0, imgTop.Width, _
imgTop.Height,GraphicsUnit.Pixel)
picBox.Image = imgBack
End Sub
'''''''''''''''''''''''''''''''''''''

How to overcome this issue? Is there another approach to get a transparent
multipage TIFF?

Thanks,
BB
Jul 21 '05 #1
1 2357
Hi, BB

I notice that you posted the same message in
microsoft.public.dotnet.drawing. I have received a commitment from the GDI
tech lead to respond to you there.

Posting multiple messages in this way is called multi-posting, which is
considered poor manners in the newsgroups and will get you flamed if some
people notice. This is because an answer to one post is not available in
the other. If I answer your question in one thread and it was already
answered in another thread, I've wasted my time. The preferred technique
is called crossposting, which puts linked copies of the same post in
multiple newsgroups.. You can crosspost using Outlook Express or the MSDN
Web interface by explicitly typing the names of the groups (separated by a
comma or a semi-colon) in the Newsgroup box that appears when you post.

Example: microsoft.public.vb.com;microsoft.public.vb.databa se.ado etc.

HTH,

John Eikanger
Microsoft Visual Basic Team

This posting is provided “AS IS” with no warranties, and confers no rights.
(c) 2003 Microsoft Corporation. All rights reserved.
--------------------
| From: "news.microsoft.com" <zd***********************@sidus.hr>
| Subject: Possible bug in System.Drawing.Graphics when dealing with
multipage TIFFs and transparency
| Date: Tue, 21 Oct 2003 10:25:09 +0200
| Lines: 53
| X-Priority: 3
| X-MSMail-Priority: Normal
| X-Newsreader: Microsoft Outlook Express 6.00.2800.1106
| X-MimeOLE: Produced By Microsoft MimeOLE V6.00.2800.1106
| Message-ID: <u9**************@TK2MSFTNGP12.phx.gbl>
| Newsgroups: microsoft.public.dotnet.general
| NNTP-Posting-Host: 213.202.70.114
| Path: cpmsftngxa06.phx.gbl!TK2MSFTNGP08.phx.gbl!TK2MSFTN GP12.phx.gbl
| Xref: cpmsftngxa06.phx.gbl microsoft.public.dotnet.general:112641
| X-Tomcat-NG: microsoft.public.dotnet.general
|
| Hello group,
| My goal is to attach an image over another image.
| Top image should be transparent so the back image is visible through the
top
| one.
|
| Bellow is a test code in VB.NET. You need to create a form, a button
| (Button1) and an Picture Box (picBox).
| "watermark.jpg" is any jpg image, "beispiel.tif" is a multipage TIFF image
| with the white background, which will turn to transparent.
| The most important thing here is that the TIFF image should be a multipage
| type (multiple images in a single *.TIF file).
| You can download a multipage TIFF for testing from:
| http://www.patent-inf.tu-ilmenau.de/...e/beispiel.tif
|
| The bug(?) is:
| In the code bellow the line:
| imgTop.SelectActiveFrame(System.Drawing.Imaging.Fr ameDimension.Page, 4)
| is doing the same as
| imgTop.SelectActiveFrame(System.Drawing.Imaging.Fr ameDimension.Page, 0)
| That means, it does not select the page 4. It selects the first page
| instead, no matter we specified "4".
|
| My guess is that this odd behaviour has something to do with the
| transparency of the image, because when the line:
| imgTop.MakeTransparent(Color.White) is commented, the thing works, the
| desired page is selected, but there is no transparency and the background
| image is not visible.
|
|
| The source code:
| ''''''''''''''''''''''''''''''''''''''
| Private Sub Button1_Click(ByVal sender As System.Object, _
| ByVal e As System.EventArgs) Handles Button1.Click
| Dim imgBack As New Bitmap("d:\temp\watermark.jpg")
| Dim imgTop As Bitmap = New Bitmap("d:\temp\beispiel.tif")
| Dim g As Graphics = Graphics.FromImage(imgBack)
|
| Dim rect As New Rectangle(0, 0, imgBack.Width, imgBack.Height)
| imgTop.SelectActiveFrame(System.Drawing.Imaging.Fr ameDimension.Page,4)
| imgTop.MakeTransparent(Color.White)
| g.DrawImage(imgTop, rect, 0, 0, imgTop.Width, _
| imgTop.Height,GraphicsUnit.Pixel)
| picBox.Image = imgBack
| End Sub
| '''''''''''''''''''''''''''''''''''''
|
| How to overcome this issue? Is there another approach to get a transparent
| multipage TIFF?
|
| Thanks,
| BB
|
|
|

Jul 21 '05 #2

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

Similar topics

1
by: Paul Hoad | last post by:
I'm trying to use MeasureString() to determine the length in pixels of a string However to do I need a System.Drawing.Graphics object to do this I need to create a System.Drawing.Graphics...
1
by: DBC User | last post by:
Hi Sharpies, This is a very basic question. I am using .Net IDE 2003 and System.Drawing.dll (1.1.4322). I wrote a simple program like this (ommitting the commons) using System.Drawing; .....
1
by: Hadar | last post by:
Hi, I'm getting "object is currently in use elsewhere" when I use System.Drawing.Graphics.MesureString. This is what I do: My controls use a utility class the helps it to mesure strings. To...
3
by: Chris Calzaretta | last post by:
From: "Chris Calzaretta" <ccalzaretta@hotmail.com> Subject: Re: Is It Possible? Date: Friday, February 04, 2005 11:44 AM Ok i am posting the code I need to create a form from this web service...
1
by: news.microsoft.com | last post by:
Hello group, My goal is to attach an image over another image. Top image should be transparent so the back image is visible through the top one. Bellow is a test code in VB.NET. You need to...
4
by: Dale | last post by:
I am creating GIF images with transparent backgrounds on-the-fly for a web app and rendering them by using System.Drawing.Image.Save(Response.OutputStream, ImageType.GIF). I am confident that...
11
by: cty0000 | last post by:
I have some quiestion... I want to draw line,point,rectangles and etc... on the from So I code like this.. public update() { g = this.CreateGraphics(); g.FillRectangle(Brushes.White, x1,...
11
by: =?Utf-8?B?UmF5IE1pdGNoZWxs?= | last post by:
Hello, I know I sound like a one-note Johnny on this but I'm still looking for a solution. I need to display characters coming in from a serial port or a socket. I also need to be able to type...
0
by: MasterOfTheDark | last post by:
This one's a hairy one to explain. What I've got is a class called "VistaGroupBox" that I put some nice-looking Vista-style gradients in the background and made to look like the ribbon categories...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
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?
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...
0
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...
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...
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...

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.