GP-231 update ExportImagesScript

Use currentSelection and allow user to specify output directory.
This commit is contained in:
dev747368 2020-10-06 21:10:16 -04:00
parent 2b08598dba
commit c41e34cbf8
7 changed files with 85 additions and 50 deletions

View file

@ -319,6 +319,11 @@ public class BitmapResource {
public ImageIcon getImageIcon() {
return ResourceManager.getImageIconFromImage("Bitmap Data Image", image);
}
@Override
public String getImageFileType() {
return "bmp";
}
}
/**

View file

@ -1,6 +1,5 @@
/* ###
* IP: GHIDRA
* REVIEWED: YES
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@ -16,6 +15,7 @@
*/
package ghidra.program.model.data;
import javax.imageio.ImageIO;
import javax.swing.ImageIcon;
public abstract class DataImage {
@ -28,6 +28,15 @@ public abstract class DataImage {
*/
public abstract ImageIcon getImageIcon();
/**
* Returns the type of the underlying image data, suitable for
* {@link ImageIO#write(java.awt.image.RenderedImage, String, java.io.File)}'s formatName
* parameter.
*
* @return String image format type, ie. "png", "gif", "bmp"
*/
public abstract String getImageFileType();
/**
* Set string description (returned by toString)
* @param description

View file

@ -109,6 +109,11 @@ public class GifDataType extends BuiltIn implements Dynamic, Resource {
public ImageIcon getImageIcon() {
return new ImageIcon(data, "<GIF-Image>");
}
@Override
public String getImageFileType() {
return "gif";
}
}
@Override

View file

@ -123,6 +123,11 @@ public class JPEGDataType extends BuiltIn implements Dynamic, Resource {
public ImageIcon getImageIcon() {
return new ImageIcon(data, "<JPEG-Image>");
}
@Override
public String getImageFileType() {
return "jpg";
}
}
@Override

View file

@ -105,6 +105,11 @@ public class PngDataType extends BuiltIn implements Dynamic, Resource {
public ImageIcon getImageIcon() {
return new ImageIcon(data, "<PNG-Image>");
}
@Override
public String getImageFileType() {
return "png";
}
}
@Override

View file

@ -44,6 +44,20 @@ public class DefinedDataIterator implements DataIterator {
return new DefinedDataIterator(program, null, dataTypePredicate, null);
}
/**
* Creates a new iterator that traverses a portion of the Program's address space, returning
* data instances that successfully match the predicate.
*
* @param program Program to search
* @param addresses addresses to limit the iteration to
* @param dataTypePredicate {@link Predicate} that tests each data instance's {@link DataType}
* @return new iterator
*/
public static DefinedDataIterator byDataType(Program program, AddressSetView addresses,
Predicate<DataType> dataTypePredicate) {
return new DefinedDataIterator(program, addresses, dataTypePredicate, null);
}
/**
* Creates a new iterator that traverses the entire Program's address space, returning
* data instances that successfully match the predicate.
@ -113,8 +127,10 @@ public class DefinedDataIterator implements DataIterator {
this.dataTypePredicate = dataTypePredicate;
this.dataInstancePredicate = dataInstancePredicate;
itStack.addLast(program.getListing().getDefinedData(
(addrs == null) ? program.getMemory().getAllInitializedAddressSet() : addrs, true));
itStack.addLast(program.getListing()
.getDefinedData(
(addrs == null) ? program.getMemory().getAllInitializedAddressSet() : addrs,
true));
}
private DefinedDataIterator(Data singleDataInstance, Predicate<DataType> dataTypePredicate,