Home : Annotations : Storage : Burn transparent Annotations on a 1 bit Image
Q10117 - HOWTO: Burn transparent Annotations on a 1 bit Image

So, you think that transparency is impossible with 1 bit images?  Well, you're right.  But that doesn't mean that we can't fake it.  A clever trick is to burn the annotation, with transparency, into an 8-bit greyscale image.  Then convert that image to 1 bit.  This will create the illusion that the annotation is transparent.

For this example I started off with an 8-bit greyscale image and drew a red rectangleAnnotation with alpha value of 100.  The Code for this is simply,

[C#]

this.annotateViewer1.Annotations.CreateAnnotation(new RectangleAnnotation(new Pen(Color.Red),new SolidBrush(Color.FromArgb(100, 255,0,0))));

[VB.NET]

Me.annotateViewer1.Annotations.CreateAnnotation(New RectangleAnnotation(New Pen(Color.Red),New SolidBrush(Color.FromArgb(100, 255,0,0))))

Next, I burned the annotation onto the greyscale image.  Finally, I converted the Image to 1-bit.

[C#]

this.annotateViewer1.Burn();
foreach(Layer l in this.annotateViewer1.Annotations.Layers)
l.Clear();
this.annotateViewer1.Refresh();
AtalaImage tmpImage = this.annotateViewer1.Image;
this.annotateViewer1.Image = tmpImage.GetChangedPixelFormat(PixelFormat.Pixel1bppIndexed);

[VB.NET]

Me.annotateViewer1.Burn()
For Each l As Layer In Me.annotateViewer1.Annotations.Layers
l.Clear()
Next l
Me.annotateViewer1.Refresh()
Dim tmpImage As AtalaImage = Me.annotateViewer1.Image
Me.annotateViewer1.Image = tmpImage.GetChangedPixelFormat(PixelFormat.Pixel1bppIndexed)

There, thats it!  The last image was left in such a large size so it can be seen that the conversion actually looks pretty good.  This process can be used on any transparent Annotation. 

Related Articles
No Related Articles Available.

Article Attachments
No Attachments Available.

Related External Links
No Related Links Available.
Help us improve this article...
What did you think of this article?

poor 
1
2
3
4
5
6
7
8
9
10

 excellent
Tell us why you rated the content this way. (optional)
 
Approved Comments...
No user comments available for this article.

Powered By InstantKB.NET v1.3
Copyright © 2002, 2017. InstantASP Ltd. All Rights Reserved