cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 

Diagram SaveAsPicture Error

abaidas
Super Contributor

Hi community,

 

We are facing the error below when we try to save diagrams in image format using the java API   :

 

abaidas_0-1591866639859.png

Exception in thread "main" MEGA Error 0x80040a00
at com.mega.modeling.api.jni.MegaDrawingJNI.SaveAsPicture(Native Method)
at com.mega.modeling.api.jni.MegaDrawingProxy.saveAsPicture(Unknown Source)
at carto.intra.com.Cartoextract.ExtractDataDiag(Cartoextract.java:768)
at carto.intra.com.Cartoextract.ExtractDataOfApp(Cartoextract.java:187)
at carto.intra.com.Cartoextract.main(Cartoextract.java:90)

 

Here is the java code we use :

diagram=(MegaObject)colDiagIter.next();

 

//Récupération des propriétés de daigramme
DiagName=diagram.getProp("Name");

//Récupération du dessin
md=(MegaDrawing)MegaServiceBuilder.getDrawingOf(diagram);
height=md.getDrawingBoundHeight()*2;
withd=md.getDrawingBoundWidth()*2;

//sauvegarde des cartos dans les repertoires sous format jpeg
md.saveAsPicture(RepStockage+"//"+DiagName+".jpg",1, 24, 100, 96,height, withd);

 

Best Regards

Asmaa

3 Replies

abaidas
Super Contributor

Hi community,

 

We resolved the problem. For information in case you face the same issue. The exception GDI+ was caused by 2 reasons :

 

  • The name of the repository and the name of the picture shouldn't contain any special charatcter. We used this code to replace all special symbol with "_" :

DiagName=sansAccent(diagram.getProp("Name")).replaceAll("[^\\p{Alpha}\\p{Digit}]+","_")

 

  • The size (height and width ) of the image was not right. We changed the formula in this way:

 md=(MegaDrawing)MegaServiceBuilder.getDrawingOf(diagram);
height=md.getPageHeight()*(md.getNumberOfVerticalPages()+1);

withd=md.getPageWidth()*(md.getNumberOfHorizontalPages()+1);

 

Best Regards,

Asmaa

abaidas
Super Contributor

Hi Jerome,

 

OK. we will try to change parameters.

 

Thank you.

Asmaa

jhorber
MEGA
MEGA

 

GDIplus is a windows library used by HOPEX

Error looks related to this library

 

General recommendations

  • Apply last Windows fixes
  • Try other parameters in particular other image format
Jerome