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 : Thursday, October 26, 2006 1:24:40 AM(UTC)

sss  
sss

Groups: Registered
Posts: 8


Hi

I have a broblem with rendering Hilite annotations.
All my hilightes draws in black color, just like a redaction. Here is my code snippet:

AnnCodecs codecs = new AnnCodecs();
using (AnnContainer container = new AnnContainer())
{
container.UserMode = AnnUserMode.Run;
codecs.Load(fileName, container, 1);
container.Bounds = new AnnRectangle(0F, 0F, actualWidth, actualHeight);
container.Draw(graphics);
}

Using LeadTools 14.5.0.13 eval for .net
I have searched this forum but with no luck. Image is 24 bits and all should be fine.

Thanks
 

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 : Sunday, October 29, 2006 4:04:39 AM(UTC)

Bashar  
Guest

Groups: Guests
Posts: 3,022

Was thanked: 2 time(s) in 2 post(s)

Do you get this problem with any of the .NET annotation demos that ship
with LEADTOOLS?  If not, then please post a small test project that shows it.

Thanks,

 
#3 Posted : Monday, October 30, 2006 12:32:18 AM(UTC)

sss  
sss

Groups: Registered
Posts: 8


No, I did't get this behaviour in demos. But all .net demos use RasterImageViewer control.
In this control all is ok, hilights renders fine.
But I need to render annotations into bitmap. Shown above code snippet is coplete example how I do rendering.
Please, provide some workaround
 
#4 Posted : Tuesday, October 31, 2006 12:06:48 AM(UTC)

Bashar  
Guest

Groups: Guests
Posts: 3,022

Was thanked: 2 time(s) in 2 post(s)

Please try the Load Level Annotation demo.  This one uses the same
technique to draw the annotations as the code fragment above. 
Note that this demo draw lines, rectangles and triangles only.  I
modified it to draw hilites and didn't get the problem.  If you do
not get the problem with this demo then please put your code in a small project and post it here.

Thanks,

 
#5 Posted : Thursday, April 17, 2008 10:38:53 AM(UTC)

bsuresh  
bsuresh

Groups: Registered
Posts: 32


Hi,

I am using version 15 SDK with C#. When I burn the annotations onto image (using Draw method), the hilite object is drawn in black. I am using ColorResolutionCommand command and setting bpi to 24. Other objects such as rectangle etc are rendered in color but the hilites are rendered in complete black color. How can I resolve this issue?
Thanks,
Suresh
 
#6 Posted : Thursday, April 17, 2008 10:39:17 AM(UTC)

bsuresh  
bsuresh

Groups: Registered
Posts: 32


Even for color images, the same issue is observed.
 
#7 Posted : Thursday, April 17, 2008 11:29:05 AM(UTC)

GregR  
GregR

Groups: Registered, Tech Support, Administrators
Posts: 764


Please send a small sample project (NOT your entire application) that isolates this problem so I can try to reproduce it here.

NOTE: If you are attaching a project or file to the forums...
1.) Zip the file(s) up.
2.) Make sure it is less than 5 MB.  If it is larger, please send an email to support@leadtools.com and we'll send you FTP instructions.
3.) Remove ANY AND ALL unlock codes and LEADTOOLS DLLs.
4.) Do not click the preview button, the attachment will not show up when you post it.
 
If you do not wish to post your file(s) on the forum since they are publically viewable, please send an email to support@leadtools.com and make sure that you include a link to this forum post.

 
#8 Posted : Friday, April 18, 2008 7:32:34 AM(UTC)

bsuresh  
bsuresh

Groups: Registered
Posts: 32


The code is part of other functions and it is difficult to separate the code. Below is the code block used for realising annotations. All objects are retaining the color and opacity but the hilite object becomes a black box.

int xres = image.XResolution;
int yres = image.YResolution;

image.XResolution = 96;
image.YResolution = 96;

foreach (AnnObject annObject in container.Objects)
{
annObject.Draw(image.CreateGdiPlusGraphics().Graphics);
}

image.XResolution = xres;
image.YResolution = yres;
 
#9 Posted : Friday, April 18, 2008 10:20:25 AM(UTC)

GregR  
GregR

Groups: Registered, Tech Support, Administrators
Posts: 764


Here's a  code snippet that will corectly realize the hilite annotation onto the image:


private void Realize(RasterImageViewer viewer, AnnContainer container)
{
    // to realize, we do the following:
    // 1. set an identity transform into container (we dont care how zoomed or scrolled it is)
    // 2. disable the image events (so as only 1 event fires at the end)
    // 3. disable the container's DrawObject events.  If any designer is working on the container,
    //    it uses these events to draw the handles and what not.  We do not want them when we realize.
    // 4. Obtain a Graphics from the image.
    // 5. Call AnnContainer.Draw on this graphics
    // 6. Restore everything

    // save the current matrix in the container
    Matrix saveTransform = container.Transform;

    // we do not want to paint the handles (if any)
    container.DisableDrawObjectEvents();

    // disable the events on the image
    viewer.Image.DisableEvents();

    try
    {
        // create an HDC from the image
        // note, we can call IRasterImage.CreateGraphics here.  But to creating a
        // a GDI+ Graphics directly only would convert 1 bpp images into 24 bpp.
        // This is a better method
        IntPtr hdc = viewer.Image.CreateLeadDC();

        using (Matrix transform = new Matrix())
        {
            // apply the new transformation (identity)
            container.Transform = transform;

            try
            {
                // get a Graphics from this HDC and draw the container on it
                using (Graphics g = Graphics.FromHdc(hdc))
                    container.Draw(g);
            }
            finally
            {
                if (hdc != IntPtr.Zero)
                    RasterImage.DeleteLeadDC(hdc);
                    //viewer.Image.DeleteLeadDC(hdc);
            }
        }
    }
    finally
    {
        // the image has been changed
        viewer.Image.EnableEvents();
        viewer.Image.OnChanged(new RasterImageChangedEventArgs(RasterImageChangedFlags.Size | RasterImageChangedFlags.Data));

        // restore the object events and the original transform
        container.EnableDrawObjectEvents();
        container.Transform = saveTransform;
    }
}

 
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.152 seconds.