public void Draw(Graphics2D graphics) { Fill f = GetFill(); Dimension pg = Sheet.GetSlideShow().GetPageSize(); Rectangle anchor = new Rectangle(0, 0, pg.width, pg.height); switch (f.GetFillType()) { case Fill.FILL_SOLID: Color color = f.GetForegroundColor(); graphics.SetPaint(color); graphics.Fill(anchor); break; case Fill.FILL_PICTURE: PictureData data = f.GetPictureData(); if (data is Bitmap) { BufferedImage img = null; try { img = ImageIO.Read(new MemoryStream(data.Data)); } catch (Exception e) { logger.log(POILogger.WARN, "ImageIO failed to create image. image.type: " + data.GetType()); return; } Image scaledImg = img.GetScaledInstance(anchor.width, anchor.height, Image.SCALE_SMOOTH); graphics.DrawImage(scaledImg, anchor.x, anchor.y, null); } break; default: logger.log(POILogger.WARN, "unsuported fill type: " + f.GetFillType()); break; } }
/// <summary> /// ColorConverts the source BufferedImage. /// If the destination image is null, /// a BufferedImage will be created with an appropriate ColorModel. </summary> /// <param name="src"> the source <code>BufferedImage</code> to be converted </param> /// <param name="dest"> the destination <code>BufferedImage</code>, /// or <code>null</code> </param> /// <returns> <code>dest</code> color converted from <code>src</code> /// or a new, converted <code>BufferedImage</code> /// if <code>dest</code> is <code>null</code> </returns> /// <exception cref="IllegalArgumentException"> if dest is null and this op was /// constructed using the constructor which takes only a /// RenderingHints argument, since the operation is ill defined. </exception> public BufferedImage Filter(BufferedImage src, BufferedImage dest) { ColorSpace srcColorSpace, destColorSpace; BufferedImage savdest = null; if (src.ColorModel is IndexColorModel) { IndexColorModel icm = (IndexColorModel)src.ColorModel; src = icm.ConvertToIntDiscrete(src.Raster, true); } srcColorSpace = src.ColorModel.ColorSpace; if (dest != null) { if (dest.ColorModel is IndexColorModel) { savdest = dest; dest = null; destColorSpace = null; } else { destColorSpace = dest.ColorModel.ColorSpace; } } else { destColorSpace = null; } if ((CSList != null) || (!(srcColorSpace is ICC_ColorSpace)) || ((dest != null) && (!(destColorSpace is ICC_ColorSpace)))) { /* non-ICC case */ dest = NonICCBIFilter(src, srcColorSpace, dest, destColorSpace); } else { dest = ICCBIFilter(src, srcColorSpace, dest, destColorSpace); } if (savdest != null) { Graphics2D big = savdest.CreateGraphics(); try { big.DrawImage(dest, 0, 0, null); } finally { big.Dispose(); } return(savdest); } else { return(dest); } }
//**************************************************************** // Painting - Methods for painting a PImage. //**************************************************************** /// <summary> /// Overridden. See <see cref="PNode.Paint">PNode.Paint</see>. /// </summary> protected override void Paint(PPaintContext paintContext) { if (Image != null) { RectangleF b = Bounds; Graphics2D g = paintContext.Graphics; g.DrawImage(image, b.X, b.Y); } }
///////////////////////////////////////////////////////////////////////////// //--------------------------------- REVISIONS ------------------------------- // Date Name Tracking # Description // --------- ------------------- ------------- ----------------------- // 21JUN2009 James Shen Initial Creation ///////////////////////////////////////////////////////////////////////////// /** * Draws the specified characters using the given font. * The offset and Length parameters must specify a valid range of characters * within the character array data. The offset parameter must be within the * range [0..(data.Length)], inclusive. The Length parameter must be a * non-negative integer such that (offset + Length) <= data.Length. * @param font the font object. * @param str the array of characters to be drawn. * @param X the X coordinate of the anchor point. * @param Y the Y coordinate of the anchor point. */ private void DrawString(IFont font, string str, int x, int y) { lock (_textGraphics) { _textGraphics.SetColor(_fontTranspency); _textGraphics.FillRect(0, 0, _textImage.GetWidth(), _textImage.GetHeight()); _textGraphics.SetFont(font); _textGraphics.SetColor(_fontColor); _textGraphics.DrawString(str, 0, 0); SharedGraphics2D.DrawImage(_textImage.GetRGB(), MapLayer.MAP_TILE_WIDTH, IMAGE_PATERN_WIDTH, x, y, _fontTranspency); } }
public override void Draw(Graphics2D g) { if (drawHUD) { GameControl.HUD.Draw(g, true); g.Translate(0, 16); } g.DrawImage(backgroundSprite, Point2I.Zero); if (currentSlotGroup != null) { DrawSlotCursor(g, currentSlotGroup.CurrentSlot); } for (int i = 0; i < slotGroups.Count; i++) { slotGroups[i].Draw(g); } }
//----------------------------------------------------------------------------- // Drawing //----------------------------------------------------------------------------- // Called every step to draw the game. public void Draw(Graphics2D g) { g.UseIntegerPrecision = true; // Render the game-state stack to a buffer. g.SetRenderTarget(GameData.RenderTargetGame); g.Begin(GameSettings.DRAW_MODE_DEFAULT); g.Clear(Color.Black); gameStateStack.Draw(g); g.End(); // Draw the buffer to the screen scaled. g.SetRenderTarget(null); g.ResetTranslation(); g.Begin(GameSettings.DRAW_MODE_DEFAULT); g.DrawImage(GameData.RenderTargetGame, Vector2F.Zero, Vector2F.Zero, new Vector2F(gameScale, gameScale), 0.0); g.End(); }
//----------------------------------------------------------------------------- // Overriden methods //----------------------------------------------------------------------------- protected override void Draw() { Graphics2D g = new Graphics2D(spriteBatch); //g.SetRenderTarget(GameData.RenderTargetGame); g.Begin(GameSettings.DRAW_MODE_DEFAULT); g.Clear(Color.White); g.Translate(new Vector2F(-this.HorizontalScroll.Value, -this.VerticalScroll.Value)); g.DrawImage(Tileset.SpriteSheet.Image.GetVariant(Zone.ImageVariantID), Point2I.Zero); Point2I tilePoint = SelectedTile * (Tileset.SpriteSheet.CellSize + Tileset.SpriteSheet.Spacing); g.DrawRectangle(new Rectangle2I(tilePoint, Tileset.SpriteSheet.CellSize + 1), 1, Color.White); g.DrawRectangle(new Rectangle2I(tilePoint + 1, Tileset.SpriteSheet.CellSize - 1), 1, Color.Black); g.DrawRectangle(new Rectangle2I(tilePoint - 1, Tileset.SpriteSheet.CellSize + 3), 1, Color.Black); g.ResetTranslation(); g.End(); }
public override void Draw(Graphics2D g) { Zone zoneOld = OldRoomControl.Room.Zone; Zone zoneNew = NewRoomControl.Room.Zone; if (zoneOld == zoneNew) { // Draw the rooms normally. DrawRooms(g); } else { // Fade between zones. // Switch to the temp render target to draw the new zone. g.End(); g.SetRenderTarget(GameData.RenderTargetGameTemp); g.Begin(GameSettings.DRAW_MODE_DEFAULT); OldRoomControl.Room.Zone = zoneNew; DrawRooms(g); OldRoomControl.Room.Zone = zoneOld; // Switch to main render target to draw the old zone. g.End(); g.SetRenderTarget(GameData.RenderTargetGame); g.Begin(GameSettings.DRAW_MODE_DEFAULT); NewRoomControl.Room.Zone = zoneOld; DrawRooms(g); NewRoomControl.Room.Zone = zoneNew; // Draw the temp render target (with the new zone) at an opacity. float opacity = (float)distance / (float)maxDistance; Color color = Color.White * opacity; g.DrawImage(GameData.RenderTargetGameTemp, Vector2F.Zero, Vector2F.Zero, Vector2F.One, 0.0, color); } // Draw the HUD. GameControl.HUD.Draw(g, false); }
public override void Draw(Graphics2D g) { if (dungeon == null) { return; } // Draw the background. g.DrawImage(backgroundImage, Point2I.Zero); // TODO: Draw the dungeon name panel. // Draw the floors. Point2I floorBasePos = new Point2I(); if (floors.Count < 6) { floorBasePos.Y = 72 + (8 * (floors.Count / 2)); } else { floorBasePos.Y = 88 + (4 * (floors.Count - 6)); } for (int i = 0; i < floors.Count; i++) { DungeonMapFloor floor = floors[i]; if (discoveredFloors.Contains(floor)) { // Draw the floor's label box on the left side of the screen. Point2I floorPos = floorBasePos - new Point2I(0, i * 8); string floorName = floor.FloorNumberText; g.DrawString(GameData.FONT_SMALL, floorName, floorPos, new Color(248, 248, 216)); // drop shadow g.DrawString(GameData.FONT_SMALL, floorName, floorPos + new Point2I(0, -1), new Color(56, 32, 16)); g.DrawSprite(GameData.SPR_UI_MAP_FLOOR_BOX_LEFT, GameData.VARIANT_LIGHT, floorPos + new Point2I(32, 0)); g.DrawSprite(GameData.SPR_UI_MAP_FLOOR_BOX_RIGHT, GameData.VARIANT_LIGHT, floorPos + new Point2I(40, 0)); // Draw the icons around the name box. if (viewFloor == floor) { g.DrawSprite(GameData.SPR_UI_MAP_FLOOR_INDICATOR, GameData.VARIANT_LIGHT, floorPos + new Point2I(24, 0)); } if (playerFloorNumber == floor.FloorNumber) { g.DrawSprite(GameData.SPR_UI_MAP_PLAYER, GameData.VARIANT_LIGHT, floorPos + new Point2I(36, 0)); } if (floor.IsBossFloor && dungeon.HasCompass) { g.DrawSprite(GameData.SPR_UI_MAP_BOSS_FLOOR, GameData.VARIANT_LIGHT, floorPos + new Point2I(48, 0)); } // Draw the floor's room display on the right side of the screen. int discoveredFloorIndex = discoveredFloors.IndexOf(floor); Point2I floorRoomDisplayPos = new Point2I(80, 40 - (80 * discoveredFloorIndex) + floorViewPosition); if (floorRoomDisplayPos.Y < GameSettings.SCREEN_HEIGHT && floorRoomDisplayPos.Y > -80) { DrawFloor(g, floor, floorRoomDisplayPos); } // Draw room display cursor. if (!isChangingFloors && viewFloor == floor && cursorTimer < 32) { Point2I drawPos = floorRoomDisplayPos + (playerRoomLocation * 8); g.DrawSprite(GameData.SPR_UI_MAP_CURSOR, GameData.VARIANT_LIGHT, drawPos); } } } // Draw floor view traversal arrows. if (!isChangingFloors) { if (viewFloorIndex > 0) { g.DrawSprite(GameData.SPR_UI_MAP_ARROW_DOWN, GameData.VARIANT_LIGHT, 108, 108); } if (viewFloorIndex < discoveredFloors.Count - 1) { g.DrawSprite(GameData.SPR_UI_MAP_ARROW_UP, GameData.VARIANT_LIGHT, 108, 28); } } // Draw the items panel. if (dungeon.HasMap) { g.DrawSprite(GameData.SPR_REWARD_MAP, GameData.VARIANT_LIGHT, 8, 110); } if (dungeon.HasCompass) { g.DrawSprite(GameData.SPR_REWARD_COMPASS, GameData.VARIANT_LIGHT, 32, 110); } if (dungeon.HasBossKey) { g.DrawSprite(GameData.SPR_REWARD_BOSS_KEY, GameData.VARIANT_LIGHT, 8, 128); } if (dungeon.NumSmallKeys > 0) { g.DrawSprite(GameData.SPR_REWARD_SMALL_KEY, GameData.VARIANT_LIGHT, 32, 128); g.DrawString(GameData.FONT_SMALL, "X" + dungeon.NumSmallKeys.ToString(), new Point2I(40, 136), new Color(144, 136, 16)); // drop shadow g.DrawString(GameData.FONT_SMALL, "X" + dungeon.NumSmallKeys.ToString(), new Point2I(40, 136 - 1), new Color(32, 24, 16)); } }
private BufferedImage ICCBIFilter(BufferedImage src, ColorSpace srcColorSpace, BufferedImage dest, ColorSpace destColorSpace) { int nProfiles = ProfileList.Length; ICC_Profile srcProfile = null, destProfile = null; srcProfile = ((ICC_ColorSpace)srcColorSpace).Profile; if (dest == null) { /* last profile in the list defines * the output color space */ if (nProfiles == 0) { throw new IllegalArgumentException("Destination ColorSpace is undefined"); } destProfile = ProfileList [nProfiles - 1]; dest = CreateCompatibleDestImage(src, null); } else { if (src.Height != dest.Height || src.Width != dest.Width) { throw new IllegalArgumentException("Width or height of BufferedImages do not match"); } destProfile = ((ICC_ColorSpace)destColorSpace).Profile; } /* Checking if all profiles in the transform sequence are the same. * If so, performing just copying the data. */ if (srcProfile == destProfile) { bool noTrans = true; for (int i = 0; i < nProfiles; i++) { if (srcProfile != ProfileList[i]) { noTrans = false; break; } } if (noTrans) { Graphics2D g = dest.CreateGraphics(); try { g.DrawImage(src, 0, 0, null); } finally { g.Dispose(); } return(dest); } } /* make a new transform if needed */ if ((ThisTransform == null) || (ThisSrcProfile != srcProfile) || (ThisDestProfile != destProfile)) { UpdateBITransform(srcProfile, destProfile); } /* color convert the image */ ThisTransform.colorConvert(src, dest); return(dest); }
/// <summary> /// {@inheritDoc} /// </summary> public override void Draw(Graphics2D graphics, float x, float y) { graphics.DrawImage(FImage, (int)(x - FOriginX), (int)(y - FOriginY), null); }
//----------------------------------------------------------------------------- // Overriden methods //----------------------------------------------------------------------------- protected override void Draw() { Graphics2D g = new Graphics2D(spriteBatch); //g.SetRenderTarget(GameData.RenderTargetGame); g.Begin(GameSettings.DRAW_MODE_DEFAULT); Point2I selectedTileLocation = GetSelectedTileLocation(); // Draw the tileset. g.Clear(Color.White); g.Translate(-this.HorizontalScroll.Value, -this.VerticalScroll.Value); if (Tileset.SpriteSheet == null) { // Draw each tile's sprite seperately. for (int y = 0; y < Tileset.Height; y++) { for (int x = 0; x < Tileset.Width; x++) { BaseTileData tileData = Tileset.GetTileData(x, y); if (tileData != null) { int spacing = 1; Vector2F drawPos = new Vector2F(x, y) * (Tileset.CellSize + spacing); SpriteAnimation spr = tileData.Sprite; int imageVariantID = tileData.Properties.GetInteger("image_variant", Zone.ImageVariantID); if (imageVariantID < 0) { imageVariantID = Zone.ImageVariantID; } if (spr.IsAnimation) { int substripIndex = tileData.Properties.GetInteger("substrip_index", 0); spr.Animation = spr.Animation.GetSubstrip(substripIndex); } g.DrawAnimation(tileData.Sprite, imageVariantID, 0.0f, drawPos, Color.White); } } } } else { // Draw the spritesheet's image. g.Translate(-Tileset.SpriteSheet.Offset); g.DrawImage(Tileset.SpriteSheet.Image.GetVariant(Zone.ImageVariantID), Point2I.Zero); g.ResetTranslation(); } // Draw the selection box. if (selectedTileLocation >= Point2I.Zero) { Point2I tilePoint = selectedTileLocation * (Tileset.CellSize + Tileset.Spacing); g.Translate(-this.HorizontalScroll.Value, -this.VerticalScroll.Value); g.DrawRectangle(new Rectangle2I(tilePoint, Tileset.CellSize + 1), 1, Color.White); g.DrawRectangle(new Rectangle2I(tilePoint + 1, Tileset.CellSize - 1), 1, Color.Black); g.DrawRectangle(new Rectangle2I(tilePoint - 1, Tileset.CellSize + 3), 1, Color.Black); g.ResetTranslation(); } g.End(); }