Skip to content

Commit e3c8231

Browse files
committed
- Tweaked logic in the Image.addImage(). Added special case for transparent GIFs. They are (incorrectly) identified as TYPE_BYTE_BINARY (12). This resulted in black and white images for images that should have been ARGB.
- Updated comments git-svn-id: svn://192.168.0.80/JavaXT/javaxt-core@277 2c7b0aa6-e0b2-3c4e-bb4a-8b65b6c465ff
1 parent 0c870ef commit e3c8231

File tree

2 files changed

+19
-17
lines changed

2 files changed

+19
-17
lines changed

src/javaxt/io/Image.java

Lines changed: 15 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -109,7 +109,15 @@ public Image(RenderedImage img) {
109109
//**************************************************************************
110110
//** Image
111111
//**************************************************************************
112-
/** Used to create a new image from text. */
112+
/** Used to create a new image from text.
113+
* @param fontName Name of the font you with to use. Note that you can get
114+
* a list of available fonts like this:
115+
<pre>
116+
for (String fontName : GraphicsEnvironment.getLocalGraphicsEnvironment().getAvailableFontFamilyNames()){
117+
System.out.println(fontName);
118+
}
119+
</pre>
120+
*/
113121

114122
public Image(String text, String fontName, int fontSize, int r, int g, int b){
115123
this(text, new Font(fontName, Font.TRUETYPE_FONT, fontSize), r,g,b);
@@ -232,16 +240,8 @@ private static String[] getFormats(String[] inputFormats){
232240
}
233241
}
234242

235-
//Convert the HashSet into an Array
236-
int x = 0;
237-
inputFormats = new String[formats.size()];
238-
Iterator<String> format = formats.iterator();
239-
while(format.hasNext()){
240-
inputFormats[x] = format.next();
241-
x++;
242-
}
243-
244-
//Sort and return the array
243+
//Sort and return the hashset as an array
244+
inputFormats = formats.toArray(new String[formats.size()]);
245245
java.util.Collections.sort(java.util.Arrays.asList(inputFormats));
246246
return inputFormats;
247247
}
@@ -433,7 +433,10 @@ else if(y>h){
433433

434434
//Create new image "collage"
435435
if (w>bufferedImage.getWidth() || h>bufferedImage.getHeight()){
436-
int imageType = BufferedImage.TYPE_INT_ARGB;
436+
int imageType = bufferedImage.getType();
437+
if (imageType == 0 || imageType == 12) {
438+
imageType = BufferedImage.TYPE_INT_ARGB;
439+
}
437440
BufferedImage bi = new BufferedImage(w, h, imageType);
438441
Graphics2D g2d = bi.createGraphics();
439442
java.awt.Image img = bufferedImage;

src/javaxt/utils/Date.java

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -462,12 +462,11 @@ public boolean isAfter(javaxt.utils.Date Date){
462462
//**************************************************************************
463463
//** Add
464464
//**************************************************************************
465-
/** Used to add to (or subtract from) the current date.
466-
* Returns a date to which a specified time interval has been added.
467-
* @param units Units of measure (e.g. hours, minutes, seconds, weeks,
465+
/** Used to add to (or subtract from) the current date. Returns a date to
466+
* which a specified time interval has been added.
467+
* @param units Unit of measure (e.g. hours, minutes, seconds, days, weeks,
468468
* months, years, etc.)
469-
*/
470-
469+
*/
471470
public java.util.Date add(int amount, String units){
472471

473472
Calendar cal = Calendar.getInstance();

0 commit comments

Comments
 (0)