// Overridable function which generates the image for a tile on the map. // Child classes could choose override "TileDrawer" instead. The advantage of overriding // this function is that the image will be cached. protected virtual Cairo.Surface GenerateTileImage(int x, int y) { RoomLayout layout = GetRoomLayout(x, y); var tileSurface = this.Window.CreateSimilarSurface(Cairo.Content.Color, (int)(layout.Width * 16 * _scale), (int)(layout.Height * 16 * _scale)); // The below line works fine, but doesn't look as good on hidpi monitors //_surface = new Cairo.ImageSurface(Cairo.Format.Rgb24, // (int)(layout.Width * 16 * _scale), (int)(layout.Height * 16 * _scale)); Bitmap img = layout.GetImage(); using (var cr = new Cairo.Context(tileSurface)) using (var source = new BitmapSurface(img)) { cr.Scale(_scale, _scale); cr.SetSource(source, 0, 0); cr.Paint(); } return(tileSurface); }