Ejemplo n.º 1
0
 public static BufferedImage getCardImage(IRenderableCard cardDef) {
   File cropFile = MagicFileSystem.getCroppedCardImageFile(cardDef);
   if (cropFile.exists()) {
     if (cardDef.isPlaneswalker()) {
       BufferedImage crop =
           GraphicsUtils.scale(ImageFileIO.toImg(cropFile, MagicImages.MISSING_CARD), 320, 234);
       if (OracleText.getPlaneswalkerAbilityCount(cardDef) == 3) {
         BufferedImage blend = ResourceManager.newFrame(ResourceManager.getPlaneswalkerImageBlend);
         return Frame.getBlendedFrame(
             new BufferedImage(320, 234, BufferedImage.TYPE_INT_ARGB), blend, crop);
       } else {
         BufferedImage cropSmall = crop.getSubimage(0, 0, 320, 201);
         BufferedImage blend =
             GraphicsUtils.scale(
                 ResourceManager.newFrame(ResourceManager.getPlaneswalkerImageBlend), 320, 201);
         return Frame.getBlendedFrame(
             new BufferedImage(320, 210, BufferedImage.TYPE_INT_ARGB), blend, cropSmall);
       }
     } else {
       BufferedImage image = ImageFileIO.toImg(cropFile, MagicImages.MISSING_CARD);
       return GraphicsUtils.scale(image, 316, 231);
     }
   }
   if (cardDef.isPlaneswalker()) {
     return buildPlaneswalkerImage(cardDef);
   }
   return buildDefaultImage(cardDef);
 }
Ejemplo n.º 2
0
 public static BufferedImage getDefaultBackground(IRenderableCard cardDef) {
   if (cardDef.isMulti()) {
     if (cardDef.isHybrid()) {
       List<BufferedImage> colorDefaults =
           Frame.getColorPairOrder(cardDef)
               .stream()
               .filter(cardDef::hasColor)
               .map(ImageFrame::defaultBackground)
               .collect(Collectors.toList());
       return Frame.getBlendedFrame(
           ResourceManager.newFrame(colorDefaults.get(0)),
           ResourceManager.newFrame(ResourceManager.defaultHybridBlend),
           ResourceManager.newFrame(colorDefaults.get(1)));
     } else {
       return ResourceManager.newFrame(ResourceManager.defaultMulti);
     }
   }
   for (MagicColor color : MagicColor.values()) {
     if (cardDef.hasColor(color)) {
       return defaultBackground(color);
     }
   }
   if (cardDef.hasType(MagicType.Land)) {
     return ResourceManager.newFrame(ResourceManager.defaultLand);
   }
   if (cardDef.hasType(MagicType.Artifact)) {
     return ResourceManager.newFrame(ResourceManager.defaultArtifact);
   }
   return ResourceManager.newFrame(ResourceManager.defaultColorless);
 }
Ejemplo n.º 3
0
 private static BufferedImage buildPlaneswalkerImage(IRenderableCard cardDef) {
   int WIDTH = 320;
   int HEIGHT;
   BufferedImage blend;
   if (OracleText.getPlaneswalkerAbilityCount(cardDef) == 3) {
     HEIGHT = 234;
     blend = ResourceManager.newFrame(ResourceManager.getPlaneswalkerImageBlend);
   } else {
     HEIGHT = 201;
     blend =
         GraphicsUtils.scale(
             ResourceManager.newFrame(ResourceManager.getPlaneswalkerImageBlend), WIDTH, HEIGHT);
   }
   BufferedImage background = GraphicsUtils.scale(getDefaultBackground(cardDef), WIDTH, HEIGHT);
   BufferedImage symbol = GraphicsUtils.scale(getDefaultSymbol(cardDef), WIDTH, HEIGHT);
   BufferedImage image =
       Frame.getBlendedFrame(
           new BufferedImage(WIDTH, HEIGHT, BufferedImage.TYPE_INT_ARGB), blend, background);
   return getCompositeImage(image, symbol);
 }