new search modes: first, last, smallest

This commit is contained in:
Honfika
2014-02-27 23:44:18 +01:00
parent a9fa051e8a
commit 5affc79d25
4 changed files with 31 additions and 4 deletions

View File

@@ -75,6 +75,8 @@ public class SWFSearch {
"CFX".getBytes()); //Compressed ScaleForm GFx
int pos = 0;
long biggestSize = 0;
long smallestSize = Long.MAX_VALUE;
addressLoop:
for (Long addr : ret.keySet()) {
setProgress(pos * 100 / ret.size());
pos++;
@@ -100,6 +102,21 @@ public class SWFSearch {
swfStreams.clear();
swfStreams.put(addr, is);
}
break;
case SMALLEST:
if (limit < smallestSize) {
smallestSize = limit;
swfStreams.clear();
swfStreams.put(addr, is);
}
break;
case FIRST:
swfStreams.put(addr, is);
break addressLoop;
case LAST:
swfStreams.clear();
swfStreams.put(addr, is);
break;
}
}
} catch (OutOfMemoryError ome) {

View File

@@ -22,5 +22,5 @@ package com.jpexs.decompiler.flash;
*/
public enum SearchMode {
ALL, BIGGEST
ALL, BIGGEST, SMALLEST, FIRST, LAST
}

View File

@@ -124,7 +124,7 @@ public class CommandLineArgumentParser {
System.out.println(" ...Compress SWF <infile> and save it to <outfile>");
System.out.println(" 8) -decompress <infile> <outfile>");
System.out.println(" ...Decompress <infile> and save it to <outfile>");
System.out.println(" 9) -extract <infile> [-o <outpath>|<outfile>] [nocheck] [(all|biggest|first)]");
System.out.println(" 9) -extract <infile> [-o <outpath>|<outfile>] [nocheck] [(all|biggest|smallest|first|last)]");
System.out.println(" ...Extracts SWF files from ZIP or other binary files");
System.out.println(" ...-o parameter should contain a file path when \"biggest\" or \"first\" parameter is specified");
System.out.println(" ...-o parameter should contain a folder path when no exctaction mode or \"all\" parameter is specified");
@@ -787,6 +787,15 @@ public class CommandLineArgumentParser {
case "biggest":
mode = SearchMode.BIGGEST;
break;
case "smallest":
mode = SearchMode.SMALLEST;
break;
case "first":
mode = SearchMode.FIRST;
break;
case "last":
mode = SearchMode.LAST;
break;
}
}
@@ -808,7 +817,7 @@ public class CommandLineArgumentParser {
InputStream stream = streamEntry.getValue();
stream.reset();
String fileNameOut;
if (mode == SearchMode.BIGGEST) {
if (mode != SearchMode.ALL) {
if (output == null) {
fileNameOut = Path.getFileNameWithoutExtension(new File(fileName)) + ".swf";
} else {

View File

@@ -108,6 +108,7 @@ public class BitmapExporter extends ShapeExporterBase implements IShapeExporter
graphics.setRenderingHint(RenderingHints.KEY_INTERPOLATION, RenderingHints.VALUE_INTERPOLATION_BILINEAR);
graphics.setRenderingHint(RenderingHints.KEY_RENDERING, RenderingHints.VALUE_RENDER_QUALITY);
graphics.setRenderingHint(RenderingHints.KEY_ANTIALIASING, RenderingHints.VALUE_ANTIALIAS_ON);
graphics.setComposite(AlphaComposite.Src);
defaultStroke = graphics.getStroke();
super.export();
}
@@ -118,6 +119,7 @@ public class BitmapExporter extends ShapeExporterBase implements IShapeExporter
graphics.setRenderingHint(RenderingHints.KEY_INTERPOLATION, RenderingHints.VALUE_INTERPOLATION_BILINEAR);
graphics.setRenderingHint(RenderingHints.KEY_RENDERING, RenderingHints.VALUE_RENDER_QUALITY);
graphics.setRenderingHint(RenderingHints.KEY_ANTIALIASING, RenderingHints.VALUE_ANTIALIAS_ON);
graphics.setComposite(AlphaComposite.Src);
AffineTransform at = transformation.toTransform();
at.preConcatenate(AffineTransform.getScaleInstance(1 / SWF.unitDivisor, 1 / SWF.unitDivisor));
unitDivisor = 1;
@@ -377,7 +379,6 @@ public class BitmapExporter extends ShapeExporterBase implements IShapeExporter
if (fillPaint != null) {
if (fillPaint instanceof MultipleGradientPaint) {
AffineTransform oldAf = graphics.getTransform();
graphics.setComposite(AlphaComposite.Src);
if (fillPathPaint != null) {
graphics.setPaint(fillPathPaint);
}