-
Notifications
You must be signed in to change notification settings - Fork 599
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Extract WMF-specific logic from ImgWMF into
- Loading branch information
1 parent
1b065aa
commit 9834d9b
Showing
3 changed files
with
52 additions
and
22 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
package com.lowagie.text; | ||
|
||
public class WMFData { | ||
public final float scaledWidth; | ||
public final float scaledHeight; | ||
public final float dpiX; | ||
public final float dpiY; | ||
|
||
public WMFData(float scaledWidth, float scaledHeight, float dpiX, float dpiY) { | ||
this.scaledWidth = scaledWidth; | ||
this.scaledHeight = scaledHeight; | ||
this.dpiX = dpiX; | ||
this.dpiY = dpiY; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,29 @@ | ||
package com.lowagie.text; | ||
|
||
import com.lowagie.text.error_messages.MessageLocalization; | ||
import com.lowagie.text.pdf.codec.wmf.InputMeta; | ||
import java.io.IOException; | ||
import java.io.InputStream; | ||
|
||
public class WMFProcessor { | ||
public static WMFData processWMF(InputStream is, String errorID) throws IOException, BadElementException { | ||
InputMeta in = new InputMeta(is); | ||
if (in.readInt() != 0x9AC6CDD7) { | ||
throw new BadElementException( | ||
MessageLocalization.getComposedMessage("1.is.not.a.valid.placeable.windows.metafile", errorID)); | ||
} | ||
in.readWord(); | ||
int left = in.readShort(); | ||
int top = in.readShort(); | ||
int right = in.readShort(); | ||
int bottom = in.readShort(); | ||
int inch = in.readWord(); | ||
|
||
float dpiX = 72; | ||
float dpiY = 72; | ||
float scaledHeight = (float) (bottom - top) / inch * 72f; | ||
float scaledWidth = (float) (right - left) / inch * 72f; | ||
|
||
return new WMFData(scaledWidth, scaledHeight, dpiX, dpiY); | ||
} | ||
} |