Ignore:
Timestamp:
05/10/18 16:04:51 (6 years ago)
Author:
davidb
Message:

Reworking of the code-base to separate logic from graphics. This version of Expeditee now supports a JFX graphics as an alternative to SWING

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/org/expeditee/items/FrameBitmap.java

    r919 r1102  
    1919package org.expeditee.items;
    2020
    21 import java.awt.Color;
    22 import java.awt.Image;
    23 import java.awt.image.BufferedImage;
    24 import java.awt.image.ImageObserver;
    2521import java.util.List;
    2622
     23import org.expeditee.core.Colour;
     24import org.expeditee.core.Image;
    2725import org.expeditee.gui.Frame;
    2826import org.expeditee.gui.FrameIO;
     
    3129
    3230public class FrameBitmap extends FramePicture {
    33         public FrameBitmap(Text source, ImageObserver observer, Image image){
    34                 super(source, observer, image);
     31        public FrameBitmap(Text source, Image image){
     32                super(source, image);
    3533        }
    3634
     
    5957                        return false;
    6058               
    61                 BufferedImage bi = new BufferedImage(width, height,
    62                                 BufferedImage.TYPE_INT_ARGB);
     59                Image bi = Image.createImage(width, height);
    6360                // now set the bits on the image
    64                 final int transparent = (new Color(0F, 0F, 0F, 0F)).getRGB();
    65                 final int main = _source.getPaintColor().getRGB();
    66                 final Color c = _source.getPaintColor();
     61                final int transparent = (new Colour(0F, 0F, 0F, 0F)).getARGB32BitPacked();
     62                final int main = _source.getPaintColor().getARGB32BitPacked();
     63                final Colour c = _source.getPaintColor();
    6764                int currentColor = main;
    6865                int row = 0;
     
    7471                                        // Space is transparent as is 0
    7572                                        if (Character.isDigit(currentPixel)) {
    76                                                 int alpha = Math.round((currentPixel - '0') * 25.5F);
    77                                                 currentColor = new Color(c.getRed(), c.getGreen(), c
    78                                                                 .getBlue(), alpha).getRGB();
     73                                                int alpha = Math.round((currentPixel - '0') * (Colour.COMPONENT_MAX_VALUE / 10.0f));
     74                                                currentColor = new Colour(c.getRed(), c.getGreen(), c
     75                                                                .getBlue(), alpha).getARGB32BitPacked();
    7976                                        }else if (currentPixel != ' ') {
    8077                                                currentColor = main;
    8178                                        }
    8279                                }
    83                                 bi.setRGB(i, row, currentColor);
     80                                bi.setPixel(i, row, Colour.fromARGB32BitPacked(currentColor));
    8481                        }
    8582                        row++;
     
    9289        @Override
    9390        protected Picture createPicture() {
    94                 return new FrameBitmap((Text) _source.copy(),
    95                                 _imageObserver, _image);
     91                return new FrameBitmap((Text) _source.copy(), _image);
    9692        }
    9793
Note: See TracChangeset for help on using the changeset viewer.