diff --git a/src/main/java/w2phtml/base/BinaryGraphicsDocument.java b/src/main/java/w2phtml/base/BinaryGraphicsDocument.java
index 8e524b2..af538d9 100644
--- a/src/main/java/w2phtml/base/BinaryGraphicsDocument.java
+++ b/src/main/java/w2phtml/base/BinaryGraphicsDocument.java
@@ -244,6 +244,13 @@ public class BinaryGraphicsDocument implements OutputFile {
int topOffset = offsets[0];
int croppedWidth = width - offsets[3] - offsets[1];
int croppedHeight = height - offsets[0] - offsets[2];
+ if ( croppedHeight <= 0) {
+ throw new IOException("Cropped image height < 0");
+ }
+ if ( croppedWidth <= 0 ) {
+ throw new IOException("Cropped image width < 0");
+ }
+
BufferedImage croppedImage = new BufferedImage(croppedWidth, croppedHeight, BufferedImage.TYPE_3BYTE_BGR);
int px[] = new int[croppedWidth * croppedHeight];
image.getRGB(leftOffset, topOffset, croppedWidth, croppedHeight, px, 0, croppedWidth);
@@ -290,8 +297,9 @@ public class BinaryGraphicsDocument implements OutputFile {
if (width > 0) {
Integer newWidth = (int) ( width/divider);
BufferedImage resizedImage = Scalr.resize(image, newWidth);
+ BufferedImage jpgImage = getJPGImage(resizedImage);
ByteArrayOutputStream baos = new ByteArrayOutputStream();
- ImageIO.write(resizedImage, "JPG", baos);
+ ImageIO.write(jpgImage, "JPG", baos);
this.blob = baos.toByteArray();
extractPPI();
} else {
@@ -303,6 +311,17 @@ public class BinaryGraphicsDocument implements OutputFile {
}
}
+ private BufferedImage getJPGImage(BufferedImage resizedImage) {
+ if (resizedImage.getType() == BufferedImage.TYPE_3BYTE_BGR){
+ return resizedImage;
+ }
+ BufferedImage jpgImage = new BufferedImage(resizedImage.getWidth(), resizedImage.getHeight(), BufferedImage.TYPE_3BYTE_BGR);
+ int px[] = new int[resizedImage.getWidth() * resizedImage.getHeight()];
+ resizedImage.getRGB(0, 0, resizedImage.getWidth(), resizedImage.getHeight(), px, 0, resizedImage.getWidth());
+ jpgImage.setRGB(0, 0, resizedImage.getWidth(), resizedImage.getHeight(), px, 0, resizedImage.getWidth());
+ return jpgImage;
+ }
+
private boolean isNotCropped(int[] offsets) {
return offsets[0] == 0 && offsets[1] == 0 && offsets[2] == 0 && offsets[3] == 0;
}
diff --git a/src/main/java/w2phtml/xhtml/content/TextParser.java b/src/main/java/w2phtml/xhtml/content/TextParser.java
index a6ab179..5cb75db 100644
--- a/src/main/java/w2phtml/xhtml/content/TextParser.java
+++ b/src/main/java/w2phtml/xhtml/content/TextParser.java
@@ -43,6 +43,7 @@ import w2phtml.office.OfficeStyle;
import w2phtml.office.PageLayout;
import w2phtml.office.StyleWithProperties;
import w2phtml.office.XMLString;
+import w2phtml.pageSplitters.ListBreaksFix;
import w2phtml.pageSplitters.SplitFactory;
import w2phtml.util.Misc;
import w2phtml.xhtml.Converter;
@@ -174,6 +175,8 @@ public class TextParser extends Parser {
//ODFPageSplitter.splitOfficeText(onode, ofr);
//Debug.prettyPrintXml(onode.getOwnerDocument());
SplitFactory splitters = new SplitFactory(ofr);
+ ListBreaksFix listBreaksFix = new ListBreaksFix(ofr);
+ listBreaksFix.addSPBsBeforeBreaksInLists(onode);
splitters.split(onode);
//Debug.prettyPrintXml(onode.getOwnerDocument());
}