Welcome Guest! To enable all features, please Login or Register.

Notification

Icon
Error

Options
View
Last Go to last post Unread Go to first unread post
#1 Posted : Wednesday, May 30, 2012 5:00:01 AM(UTC)
rajknoida

Groups: Registered
Posts: 20


Hi,

I want to hide my raster image on load(Just for testing). I am using Following code to hide raster image:


            RasterViewer.Image.PaintIntensity = 1000;

But it is not working.



I used same for WinForms and it is working fine. Sample project is attached. I am using Leadtools 17.5 and C#.NET in WPF.

Just pass the path of file in Annotation.xaml and you will get the rasterimage.

Please help me . Thanks in advance
 

Try the latest version of LEADTOOLS for free for 60 days by downloading the evaluation: https://www.leadtools.com/downloads

Wanna join the discussion? Login to your LEADTOOLS Support accountor Register a new forum account.

#2 Posted : Wednesday, May 30, 2012 5:09:05 AM(UTC)
rajknoida

Groups: Registered
Posts: 20


Project Attached
File Attachment(s):
WpfApplication1.zip (3,220kb) downloaded 35 time(s).
 
#3 Posted : Wednesday, May 30, 2012 9:25:38 AM(UTC)

Daoud  
Daoud

Groups: Registered
Posts: 256


The PaintIntensity property has no effect in the WPF viewer because WPF does not use our GDI painting function.
If you want to hide the viewer and the image, you can set the Viewer.Visibility property to Visibility.Hidden

 
#4 Posted : Wednesday, May 30, 2012 8:04:50 PM(UTC)
rajknoida

Groups: Registered
Posts: 20


Thank you so much, It is working fine.
 
#5 Posted : Thursday, May 31, 2012 7:56:48 PM(UTC)
rajknoida

Groups: Registered
Posts: 20


Hi,

It works but later i realize that my annotations are also invisible.As per my requirement  only raster image will invisible and annotation (AnnPolyLine) should remain visible.

Please help me thanks in advance.
 
#6 Posted : Sunday, June 3, 2012 7:06:21 AM(UTC)

Daoud  
Daoud

Groups: Registered
Posts: 256


Since annotations are displayed on the RasterImageViewer, hiding the viewer will hide the annotations. However, you can use one of the following two solutions:
1) Take a copy of the image into a RasterImage object different from the viewer's Image object, then fill the viewer's Image with any solid color such as white.
When you want to restore the image, use the CombineFastCommand class to restore the image pixels.

2) Change the image's color resolution to 32 bits per pixel and fill its alpha channel with black. This causes the image to be fully transparent in the WPF control.

 
#7 Posted : Tuesday, June 5, 2012 3:48:44 AM(UTC)
rajknoida

Groups: Registered
Posts: 20


Thnaks,

I am using this and it works.

 
#8 Posted : Wednesday, June 13, 2012 3:49:41 AM(UTC)
rajknoida

Groups: Registered
Posts: 20


Hi Daoud,

Thanks for your reply.

It removes the image if i set the rasters image to null. but i found
that annotations are also going invisible and scroll bar also. i tried
to use two method provided by you above but not able to find out the ways to implement these method.

Can you please provide me a sample project?


Thanks.
 
#9 Posted : Wednesday, June 13, 2012 8:11:45 AM(UTC)

Daoud  
Daoud

Groups: Registered
Posts: 256


You should not set the image to null.
To explain the alpha hiding method (transparency), do the following:
1. Take a copy of our demo from this folder:
LEADTOOLS 17.5\Examples\DotNet3\CS\ProMainDemo
2. Modify the LoadFile() function in the demo so that loading becomes like this:
========================================
Viewer.Image = codecs.Load(fileName, 32/*instead of 0*/, Leadtools.Codecs.CodecsLoadByteOrder.BgrOrGray, 1, 1);
Leadtools.RasterImage alpha;
if (MessageBox.Show("Do you want to hide it?", "test", MessageBoxButton.YesNo) == MessageBoxResult.Yes)
   alpha = Leadtools.RasterImage.Create(Viewer.Image.Width, Viewer.Image.Height, 8, Viewer.Image.XResolution, Leadtools.RasterColor.Black);
else
   alpha = Leadtools.RasterImage.Create(Viewer.Image.Width, Viewer.Image.Height, 8, Viewer.Image.XResolution, Leadtools.RasterColor.White);
Viewer.Image.SetAlphaImage(alpha);
========================================

This code will either set the alpha channel to all black (makes image transparent or hidden) or all white (makes image solid).

This does not set the image to null or delete it. It only hides its pixels.

If you want to show it again at any time, simply call this part:
alpha = Leadtools.RasterImage.Create(Viewer.Image.Width, Viewer.Image.Height, 8, Viewer.Image.XResolution, Leadtools.RasterColor.White);
Viewer.Image.SetAlphaImage(alpha);

Please let me know if you face any problems.
 
#10 Posted : Wednesday, June 13, 2012 9:49:39 PM(UTC)
rajknoida

Groups: Registered
Posts: 20


Thanks Daoud,

I
t works as desired. Thank you so much.



 
#11 Posted : Thursday, June 14, 2012 12:23:51 AM(UTC)
rajknoida

Groups: Registered
Posts: 20


Hi Daoud,

Statement:
=======================
codecs.Load(rasterImagePath, 32/*instead of 0*/, Leadtools.Codecs.CodecsLoadByteOrder.BgrOrGray, 1, 1);
=======================

is giving "Not enough memory" exception for large file. can you please assist me to find out the reason why is this happening.  One of the file is attached. Please try to load this file.

Thanks in advance.

File Attachment(s):
8482007_13700136_HDIZdenN.tif (3,287kb) downloaded 35 time(s).
 
#12 Posted : Thursday, June 14, 2012 3:58:14 AM(UTC)

Daoud  
Daoud

Groups: Registered
Posts: 256


Since the image is very big, loading it as 32 BPP will require huge amount of memory that is why you are seeing this error.

The following workaround fixes the problem and is much faster but you can use it with images up to 8BPP. It draws the image using a Gray palette to hide it and the original palette (black/white) to display it.

Make this part Global in your code:
==================
Leadtools.RasterColor[] origPal;
==================

Put the following code inside the LoadFile() function:
=================================
Viewer.Image = codecs.Load(fileName, 1, Leadtools.Codecs.CodecsLoadByteOrder.BgrOrGray, 1, 1);
origPal = Viewer.Image.GetPalette();
var hidePal = Viewer.Image.GetPalette();
for (int i = 0; i < hidePal.Length; ++i)
{
    hidePal[i] = Leadtools.RasterColor.FromKnownColor(Leadtools.RasterKnownColor.LightGray);
}
if (MessageBox.Show("Do you want to hide it?", "test", MessageBoxButton.YesNo) == MessageBoxResult.Yes)
    Viewer.Image.SetPalette(hidePal, 0, hidePal.Length);
else
    Viewer.Image.SetPalette(origPal, 0, origPal.Length);
=================================

If you want to show it again at any time, simply call this part:
==================
Viewer.Image.SetPalette(origPal, 0, origPal.Length);
==================
 
#13 Posted : Thursday, June 14, 2012 10:10:10 PM(UTC)
rajknoida

Groups: Registered
Posts: 20







Hi Daoud,
 It is working nice. Thank you so much.

Regards,
Rajesh
 
You cannot post new topics in this forum.
You cannot reply to topics in this forum.
You cannot delete your posts in this forum.
You cannot edit your posts in this forum.
You cannot create polls in this forum.
You cannot vote in polls in this forum.

Powered by YAF.NET | YAF.NET © 2003-2024, Yet Another Forum.NET
This page was generated in 0.327 seconds.