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 : Friday, November 17, 2006 8:23:59 AM(UTC)

cmurphy  
cmurphy

Groups: Registered
Posts: 31


I have "LTANNLib.LEADRasterAnnotationClass annObj" Is there anyway I can clone this object?

I'm using version 14.5, annotation COM object with dotNet classes.

Please advice,

 

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, November 19, 2006 12:31:28 AM(UTC)

Bashar  
Guest

Groups: Guests
Posts: 3,022

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

This object doesn't have a clone method.  However, you can use the
AnnCopy method to copy the annotations to the clipboard, create a new
annotation object then use AnnPaste to paste the annotations to the new object.  Will this solve your problem?

 
#3 Posted : Tuesday, November 21, 2006 11:20:35 AM(UTC)

cmurphy  
cmurphy

Groups: Registered
Posts: 31


Actually, it's my work around bug access violation error. The case is after I've create freehand object and select it right away then it's throw exception "System.AccessViolationException: Attempted to read or write protected memory. This is often an indication that other memory is corrupt. " and then crash my program.

I have my code save annotation to file then load it back then select annotation object, now it's fine. But I thought my work around is work but kind of lame and I just want to know if there is any way to clone everything from my current annObj object somewhere so I can clear current annObj and then clone it back.

Anything?

 
#4 Posted : Wednesday, November 22, 2006 5:03:31 AM(UTC)

Bashar  
Guest

Groups: Guests
Posts: 3,022

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

As far as cloning LEADRasterAnnotationClass
object, creating a new one and copying the old one to it is the best way to go.  It is more efficient that saving and loading from disk.

If you want, I can try to investigate the access violation error, but I will need a "small" working project that shows it.

Did the method I described in the post above work for you?

 
#5 Posted : Thursday, November 30, 2006 2:33:29 PM(UTC)

cmurphy  
cmurphy

Groups: Registered
Posts: 31


You mentioned that "you can use the
AnnCopy method to copy the annotations to the clipboard, create a new
annotation object then use AnnPaste to paste the annotations to the new object...".

I try:
LTANNLib.LEADRasterAnnotationClass newm_TheAnn1 = new LTANNLib.LEADRasterAnnotationClass();
//copy all ann objects & empty clipboard before copying data to it
orgm_TheAnn1.AnnCopy(LTANNLib.AnnFMTConstants.ANN_FMT_NATIVE, false, true);
newm_TheAnn1.AnnPaste();
...

After this I have function to enumerate all ann obj but I've got 0 object. Could you point me out how to do that? or Do you have sample C# code that I can use as reference? Sorry, I'm not familiar with Clipboard.


 
#6 Posted : Sunday, December 3, 2006 3:45:39 AM(UTC)

Bashar  
Guest

Groups: Guests
Posts: 3,022

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

The new RasterAnn needs to be attached to a RasterViewer control by the
AnnParentRasterView property.  Also, there should be a bitmap
loaded in this RasterViewer.  If this approach is not suitable for
you, then there is another way to do this.  You can use
AnnSaveMemory or AnnSaveArray to save the annotations of the source
RasterAnn into a memory buffer, then use AnnLoadMemory or AnnLoadArray to load it into the new RasterAnn.

 
#7 Posted : Tuesday, December 12, 2006 7:53:57 PM(UTC)

cmurphy  
cmurphy

Groups: Registered
Posts: 31


1. Could you provide me sample code to use AnnSaveMemory & AnnSaveArray for annotation COM object in C# please?
2. Is there any difference in performance between these two?

Here is what I've tried:
1. I've created TheAnn3. Can I attach to exisitng AxLEADRasterView1 following this?
    TheAnn3.AnnParentRasterView = AxLEADRasterView1.GetOcx();
2. Or do I must create AxLEADRasterView3 for it?

3. I have code save to memory following this:
int hMemGlobal = 0;
int iSizeGlobal = 0;
short error = TheAnn1.AnnSaveMemory(ref hMemGlobal,
    LTANNLib.AnnFMTConstants.ANN_FMT_NATIVE, false/*save all*/,
    ref iSizeGlobal, LTRASTERIOLib.SaveModifyConstants.SAVE_OVERWRITE, 0);

Then I have new ann object load from memory:
error = TheAnn3.AnnLoadMemory(hMemGlobal, iSizeGlobal, 1);

I have code enumerate ann obj from TheAnn3 and got nothing.

Is there something wrong with my code?

Please advice,
 
#8 Posted : Wednesday, December 13, 2006 8:08:53 AM(UTC)

Bashar  
Guest

Groups: Guests
Posts: 3,022

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

Your code looks correct.  Does AxLEADRasterView1.Raster
have a valid bitmap in it?  If not, then this is probably the
cause.  Call CreateBitmap to create a blank bitmap to hold the annotations.

 
#9 Posted : Wednesday, December 13, 2006 2:54:55 PM(UTC)

cmurphy  
cmurphy

Groups: Registered
Posts: 31


My original code already attach TheAnn1 to AxLEADRasterView1 following this:
TheAnn1.AnnParentRasterView = AxLEADRasterView1.GetOcx();

When I attached
TheAnn3 to AxLEADRasterView1 again, would it causing this?
I really don't want to create
AxLEADRasterView3, it's lot of code change on my side.

Yes, I already have bitmap loaded in
AxLEADRasterView1.
The situation is I can't enumerate ann object from TheAnn3 but when I save both TheAnn1 & TheAnn3 to ann file and compare, it's identical. Why is that?

I just want to compare ann object of both TheAnn1 & TheAnn3 - make sure that it's correct.

Please help,
 
#10 Posted : Thursday, December 14, 2006 12:18:24 AM(UTC)

Bashar  
Guest

Groups: Guests
Posts: 3,022

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

If you have both annotation objects attached to the same AxLEADRasterView,
then try attaching them to two different ones.  I tried over here,
and it doesn't seem to work properly if you attach them both to the same
AxLEADRasterView.

 
#11 Posted : Thursday, December 14, 2006 9:41:30 AM(UTC)

cmurphy  
cmurphy

Groups: Registered
Posts: 31


Could you give me your code? I've tried attach AxLEADRasterView3 and I've saved it to file and there was nothing in a file - just a blank file.
 
#12 Posted : Thursday, December 28, 2006 6:44:49 AM(UTC)

Bashar  
Guest

Groups: Guests
Posts: 3,022

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

This is the project I have been testing with.  It's in VB, but the same applies in C#.

File Attachment(s):
VBCOMANN.zip (3kb) downloaded 31 time(s).
 
#13 Posted : Tuesday, January 16, 2007 8:46:29 PM(UTC)

cmurphy  
cmurphy

Groups: Registered
Posts: 31


I've got it. Thanks.
 
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.095 seconds.