From: fyderniX on
Hey;

I'm using the Document Imagine API from Office 2003. I need to get
away from the proprietary MDI/TIFF formats it produces. It looked
pretty simple, but it's giving me grief when I try to convert the
IPictureDisp object it creates into an Image for use with .NET:

-----begin source (C#)-----
//Take page 1
MODI.Image page_1 = (MODI.Image) doc.Images[0];

//Convert it to System.Drawing.Image
//None of these methods work
System.Drawing.Image pdf_image =
System.Drawing.Image.FromFile("a.jpg");

//Method 1
//pdf_image =
Microsoft.VisualBasic.Compatibility.VB6.Support.IPictureDispToImage(page_1.Picture);
//Method 2 (Shouldn't work -- the picture property is
a metafile)
//System.IntPtr sdf = new
System.IntPtr(page_1.Picture.Handle);
//pdf_image = Bitmap.FromHbitmap(sdf);
//Method 3
//pdf_image =
AxImageConverter.IPictureToImage((stdole.StdPicture) page_1.Picture);
//Method 4
//Graphics g =
System.Drawing.Graphics.FromImage(pdf_image);
//IntPtr gp = g.GetHdc();
//page_1.Picture.Render((int)gp, 0, 0,
page_1.Picture.Width, page_1.Picture.Height, 0, 0,
page_1.Picture.Width, page_1.Picture.Height, (System.IntPtr)null);
//g.DrawImage(pdf_image, new PointF(0.0F,0.0F));

//Works with thumbnail :-S. BLAH!
pdf_image =
AxImageConverter.IPictureToImage((stdole.StdPicture)page_1.get_Thumbnail(MiTHUMBNAIL_SIZE.miTHUMB_SIZE_LARGE));

-----end source------

The error I get is "Element not found." (Same as
this post:
http://groups.google.com/group/microsoft.public.officedev/browse_thre...)

So, I can only conclude, MODI's StdPicture object is corrupt for
Image.Picture, (Though
it works with *something,* i.e. the VB6 picture box, and
Image.get_Thumbnail works like a charm). Has anyone
gotten this to work in .NET?

SigmaX

 | 
Pages: 1
Prev: failed to import ActiveX
Next: DHCP SuperScopes