PresentationEx pres = new PresentationEx(path);
ImageEx img = null;
int slideIndex = 0;
int slideCount = pres.getSlides().getCount();
Log.i(TAG, "Slide count " + slideCount);
for (int i = 0; i < slideCount; i++)
{
slideIndex++;
//Accessing the first slide
SlideEx sl = pres.getSlides().get_Item(i);
boolean flag=false;
for (int j = 0; j < sl.getShapes().getCount(); j++)
{
// Accessing the shape with picture
com.aspose.slides.ShapeEx sh = sl.getShapes().get_Item(j);
if (sh instanceof AutoShapeEx)
{
AutoShapeEx ashp = (AutoShapeEx)sh;
if (ashp.getFillFormat().getFillType() == FillTypeEx.Picture)
{
img = ashp.getFillFormat().getPictureFillFormat().getPicture().getImage();
flag=true;
}
}
else if (sh instanceof PictureFrameEx)
{
PictureFrameEx pf = (PictureFrameEx)sh;
img = pf.getPictureFormat().getPicture().getImage();
flag=true;
}
if(flag)
{
String ImageType = img.getContentType();
ImageType=ImageType.replace("image/", "");
String ImagePath = "/storage/sdcard1/bluetooth/Image_"+Integer.toString(j+1);
android.graphics.Bitmap image=img.getImage();
//create a file to write bitmap data
File f = new File(ImagePath + "_Slide_" + Integer.toString(slideIndex+1) + "." + ImageType);
try {
f.createNewFile();
} catch (IOException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
//Convert bitmap to byte array
ByteArrayOutputStream bos = new ByteArrayOutputStream();
image.compress(CompressFormat.PNG, 0 /*ignored for PNG*/, bos);
byte[] bitmapdata = bos.toByteArray();
//write the bytes in file
FileOutputStream fos = null;
try {
fos = new FileOutputStream(f);
} catch (FileNotFoundException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
try {
fos.write(bitmapdata);
} catch (IOException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
flag=false;
}
}
}
Log.i(TAG,"Success : ExtractPPTXImages..");