Spire.Presentation is a professional PowerPoint® compatible library that enables developers to create, read, write, modify, convert and Print PowerPoint documents. Get free and professional technical support for Spire.Presentation for .NET, Java, Android, C++, Python.

Sat Apr 22, 2023 2:18 pm

I'm using spire office v8.2.0 for .net (c#) win10 64bit
I am exporting groups as images, and
Code: Select all
GroupShape.SaveAsImage()
results in blurry images

Code: Select all
Spire.Presentation.GroupShape grouped = eachshape as Spire.Presentation.GroupShape; //eachshape is Spire.Presentation.Shape
if(grouped!=null)
{
   Image saveimage;
   //saveimage = grouped.SaveAsImage(); gives a blurry image for some reason
   Bitmap TemporaryImage = new Bitmap(((Spire.Presentation.ISlide)grouped.Slide).SaveAsEMF());
   float magicnumber = 1.3333333333f;
   saveimage = TemporaryImage.Clone(new Rectangle((int)(grouped.Left * magicnumber), (int)(grouped.Top* magicnumber), (int)(grouped.Width* magicnumber), (int)(grouped.Height* magicnumber)), TemporaryImage.PixelFormat);
   TemporaryImage.Dispose();
}

This almost works. It crops things slightly wrong. The left/top/width/height coordinates of the GroupShape do not represent actual coordinates on the image the slide produces, it appears to be miss-scaled by around 33%, but not exactly. Can you suggest a cleaner way to do this? This method captures some background text if the group overlapped with it.

If not, can you show me the code to move a group to a new slide that is 100% white? (I will just export the image of this slide and crop the white)

Thanks, your support is fast and knowledgeable.

joekatana
 
Posts: 6
Joined: Thu Apr 20, 2023 7:41 am

Sun Apr 23, 2023 10:16 am

Hi,

Thank you for your inquiry.

According to your problem description, I used a PPTX document containing group shapes to conduct simulation test, and the issues of converting group shapes to images you mentioned were not reproduced. In order to help us reproduce and investigate your issues,could you please provide us with your PPT file? Thank you in advance for your assistance.

Please refer to the code below to move a group shape to a new slide.

Code: Select all
 Presentation ppt = new Presentation();
            ppt.LoadFromFile("1.pptx");
            //Gets the specified slide
            ISlide sourceSlide = ppt.Slides[0];
            //Add a new slide         
            ISlide targetSlide = ppt.Slides.Append();
            //Iterate through all slides in the document
            for (int i = 0; i < sourceSlide.Shapes.Count; i++)
            {
                Spire.Presentation.IShape shape = sourceSlide.Shapes[i];
                //Determine if the shape is a combination shape
                if (shape is GroupShape)
                {
                    GroupShape groupShape = shape as GroupShape;
                    //Duplicate combination shape
                    targetSlide.Shapes.AddShape(groupShape);
                }
            }
            Image image = targetSlide.SaveAsImage();


Sincerely,
Ella
E-iceblue support team
User avatar

Ella.Zhang
 
Posts: 42
Joined: Fri Apr 07, 2023 7:42 am

Sun Apr 23, 2023 2:47 pm

Attached is a powerpoint which yields this result when I export the groupshape using the above described Spire.Presentation.GroupShape.SaveAsImage(); methods
Image

I now notice that not all groups do this, but when it happens it's in GroupShapes.

Thanks

joekatana
 
Posts: 6
Joined: Thu Apr 20, 2023 7:41 am

Mon Apr 24, 2023 3:43 am

Hi,

Thank you for sharing.

I used your PPTX document to test exporting group shapes as images, and reproduced the issue of blurry result images. I have reported this issue to our issue tracking system with the issue ID SPIREPPT-2245. Our development team will conduct further investigation and fix it. Once there is any update, we will notify you immediately. Sorry for any inconvenience caused.

If you have any other documents with the same problem, please feel free to send them to us so that we can handle them together.

Sincerely,
Ella
E-iceblue support team
User avatar

Ella.Zhang
 
Posts: 42
Joined: Fri Apr 07, 2023 7:42 am

Mon Jun 05, 2023 9:49 am

Hello,

Thank you for your patience.
I am pleased to inform you that SPIREPPT-2245 issue has been resolved. Please feel free to download and test Spire.Presentation Pack Hotfix Version:8.6.0.
Our website link: https://www.e-iceblue.com/Download/download-presentation-for-net-now.html
Nuget link: https://www.nuget.org/packages/Spire.Presentation/8.6.0

Sincerely,
Amy
E-iceblue support team
User avatar

amy.zhao
 
Posts: 2774
Joined: Wed Jun 27, 2012 8:50 am

Wed Jun 07, 2023 2:19 am

Hello,

I am glad to tell you that new Spire.Office for .NET which includes the fix for SPIREPPT-2245 issue has been released. Please feel free to download and test Spire.Office Platinum(Hotfix) Version:8.6.0.
Our website link: https://www.e-iceblue.com/Download/download-office-for-net-now.html
Nuget link: https://www.nuget.org/packages/Spire.Office/8.6.0

Sincerely,
Amy
E-iceblue support team
User avatar

amy.zhao
 
Posts: 2774
Joined: Wed Jun 27, 2012 8:50 am

Return to Spire.Presentation

cron