473,320 Members | 1,817 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,320 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 2353
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: ryjfgjl | last post by:
ExcelToDatabase: batch import excel into database automatically...
0
by: jfyes | last post by:
As a hardware engineer, after seeing that CEIWEI recently released a new tool for Modbus RTU Over TCP/UDP filtering and monitoring, I actively went to its official website to take a look. It turned...
0
by: ArrayDB | last post by:
The error message I've encountered is; ERROR:root:Error generating model response: exception: access violation writing 0x0000000000005140, which seems to be indicative of an access violation...
1
by: PapaRatzi | last post by:
Hello, I am teaching myself MS Access forms design and Visual Basic. I've created a table to capture a list of Top 30 singles and forms to capture new entries. The final step is a form (unbound)...
1
by: CloudSolutions | last post by:
Introduction: For many beginners and individual users, requiring a credit card and email registration may pose a barrier when starting to use cloud servers. However, some cloud server providers now...
1
by: Defcon1945 | last post by:
I'm trying to learn Python using Pycharm but import shutil doesn't work
1
by: Shællîpôpï 09 | last post by:
If u are using a keypad phone, how do u turn on JavaScript, to access features like WhatsApp, Facebook, Instagram....
0
by: Faith0G | last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 3 Apr 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 former...

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.