/// <summary> /// Called when the load image key event is called. /// </summary> /// <param name="sender">The sender.</param> /// <param name="args">The <see cref="MfGames.Scene2.Images.LoadImageKeyEventArgs"/> instance containing the event data.</param> private void OnLoadImageKey(object sender, LoadImageKeyEventArgs args) { BitmapLoader systemLoader = new BitmapLoader(new FileInfo("Images/" + args.Path + ".png")); TextureLoader textureLoader = new TextureLoader(systemLoader); args.ImageKeyLoader = textureLoader; }
private void worker_DoWork(object sender, DoWorkEventArgs e) { var item = ServiceProvider.Settings.SelectedBitmap.FileItem; if (ServiceProvider.Settings.SelectedBitmap.FileItem == null) { return; } //bool fullres = e.Argument is bool && (bool) e.Argument ||LayoutViewModel.ZoomFit //bool fullres = !LayoutViewModel.ZoomFit; bool fullres = e.Argument is bool && (bool)e.Argument; if ((!File.Exists(item.LargeThumb) && item.IsJpg && File.Exists(item.FileName))) { try { PhotoUtils.WaitForFile(item.FileName); ServiceProvider.Settings.SelectedBitmap.DisplayImage = (WriteableBitmap)BitmapLoader.Instance.LoadImage(item.FileName, BitmapLoader.LargeThumbSize, 0); } catch (Exception ex) { Log.Error("Unable to load fast preview", ex); } } ServiceProvider.Settings.ImageLoading = fullres || !ServiceProvider.Settings.SelectedBitmap.FileItem.IsLoaded; if (ServiceProvider.Settings.SelectedBitmap.FileItem.Loading) { while (ServiceProvider.Settings.SelectedBitmap.FileItem.Loading) { Thread.Sleep(10); } } else { BitmapLoader.Instance.GenerateCache(ServiceProvider.Settings.SelectedBitmap.FileItem); } if (!ServiceProvider.Settings.SelectedBitmap.FileItem.HaveHistogramReady()) { ServiceProvider.QueueManager.Add(new QueueItemFileItem { FileItem = ServiceProvider.Settings.SelectedBitmap.FileItem, Generate = QueueType.Histogram }); } ServiceProvider.Settings.SelectedBitmap.DisplayImage = BitmapLoader.Instance.LoadImage(ServiceProvider.Settings.SelectedBitmap.FileItem, fullres); BitmapLoader.Instance.SetData(ServiceProvider.Settings.SelectedBitmap, ServiceProvider.Settings.SelectedBitmap.FileItem); BitmapLoader.Highlight(ServiceProvider.Settings.SelectedBitmap, ServiceProvider.Settings.HighlightUnderExp, ServiceProvider.Settings.HighlightOverExp); ServiceProvider.Settings.SelectedBitmap.FullResLoaded = fullres; ServiceProvider.Settings.ImageLoading = false; GC.Collect(); Dispatcher.BeginInvoke(new Action(OnImageLoaded)); }
public string Execute(FileItem item, string dest, ValuePairEnumerator configData) { var conf = new CropTransformViewModel(configData); using (MemoryStream fileStream = new MemoryStream(File.ReadAllBytes(item.FileName))) { BitmapDecoder bmpDec = BitmapDecoder.Create(fileStream, BitmapCreateOptions.PreservePixelFormat, BitmapCacheOption.OnLoad); WriteableBitmap writeableBitmap = BitmapFactory.ConvertToPbgra32Format(bmpDec.Frames[0]); if (conf.FromLiveView && ServiceProvider.DeviceManager.SelectedCameraDevice != null) { var prop = ServiceProvider.DeviceManager.SelectedCameraDevice.LoadProperties(); conf.Left = (int)(writeableBitmap.PixelWidth * prop.LiveviewSettings.HorizontalMin / 100); conf.Width = (int) (writeableBitmap.PixelWidth * (prop.LiveviewSettings.HorizontalMax - prop.LiveviewSettings.HorizontalMin) / 100); conf.Top = (int)(writeableBitmap.Height * prop.LiveviewSettings.VerticalMin / 100); conf.Height = (int) (writeableBitmap.Height * (prop.LiveviewSettings.VerticalMax - prop.LiveviewSettings.VerticalMin) / 100); } BitmapLoader.Save2Jpg(writeableBitmap.Crop(conf.Left, conf.Top, conf.Width, conf.Height), dest); } return(dest); }
/// <summary> /// Reads the windowstyle from a filestream. /// </summary> /// <param name="binread">The System.IO.BinaryReader to use.</param> public void Open(BinaryReader binread) { _sig = new string(binread.ReadChars(4)); _version = binread.ReadInt16(); _edgeWidth = binread.ReadByte(); _backgroundMode = binread.ReadByte(); for (int i = 0; i < _edgeColors.Length; ++i) { _edgeColors[i] = new RGBA(); _edgeColors[i].ReadData(binread); } for (int i = 0; i < _edgeOffset.Length; ++i) { _edgeOffset[1] = binread.ReadByte(); } binread.ReadBytes(36); // reserved switch (_version) { case 2: for (int i = 0; i < _images.Length; ++i) { short width = binread.ReadInt16(); short height = binread.ReadInt16(); BitmapLoader loader = new BitmapLoader(width, height); _images[i] = loader.LoadFromStream(binread, width * height * 4); loader.Close(); } break; } }
public HelpScene() : base() { int size = (int)(90 * GameView.scaleFactor); Bitmap backBitmap = BitmapLoader.LoadAndResize(Resource.Drawable.back, size, size); BitmapContent backContent = new BitmapContent(backBitmap, null); int hb = (int)(80 * GameView.scaleFactor); backButton = new Button(backContent, new Rect(-hb, -hb, hb, hb), pivot, -265 * GameView.scaleFactor, -380 * GameView.scaleFactor); backButton.Pressed += () => { MenuScene.Instance.Show(Side.Left); Hide(Side.Right); }; titleText = new TextContent("GAME RULES", ColorBank.Red, 64 * GameView.scaleFactor, pivot, 0, -160 * GameView.scaleFactor); int yStart = -70, yDelta = 60; rulesText = new TextContent[4]; for (int i = 0; i < 4; ++i) { float y = (yStart + yDelta * i) * GameView.scaleFactor; rulesText[i] = new TextContent(rules[i], ColorBank.Red, 36 * GameView.scaleFactor, pivot, 0, y); } }
public void Paste() { IDataObject data = Clipboard.GetDataObject(); string[] formats = data.GetFormats(); if (formats.Length == 0) { return; } this.UpdateHistoryBefore(true); this.image.Dispose(); if (data.GetDataPresent(DataFormats.Dib)) { MemoryStream dat = (MemoryStream)data.GetData(DataFormats.Dib); this.image = BitmapLoader.BitmapFromDIB(dat); } else if (data.GetDataPresent(DataFormats.Bitmap)) { this.image = (Bitmap)data.GetData(DataFormats.Bitmap); } this.edit_layer.Dispose(); this.edit_layer = new Bitmap(this.image); this.UpdateHistoryAfter(true); this.SetSize(image.Width, image.Height); this.SetZoom(this.Zoom); }
public Sample ConvertRawBmpAsSample(Bitmap RawBmp, short VertDpi = 700, short HorDpi = 700) { VariantConverter VConverter; Enroller = new DPFP.Processing.Enrollment(); RawBmp = EncodeBitmap(RawBmp, VertDpi, HorDpi); try { // converts raw image to dpSample using DFC 2.0--------------------------------------- // encode the bmp variable using the bitmap Loader BitmapLoader BmpLoader = new BitmapLoader(RawBmp, (int)RawBmp.HorizontalResolution, (int)RawBmp.VerticalResolution); BmpLoader.ProcessBitmap(); // return the required result inputData = BmpLoader.RawData; inpRaw = BmpLoader.DPInputParam; // dispose the object BmpLoader.Dispose(); // start the conversion process VConverter = new VariantConverter(VariantConverter.OutputType.dp_sample, DataType.RawSample, inpRaw, inputData, false); MemoryStream DStream = new MemoryStream(VConverter.Convert()); DPsample = new DPFP.Sample(DStream); return(DPsample); } catch (Exception ex) { return(null /* TODO Change to default(_) if this is not a reference type */); } }
public PaintPresenter(IPaintForm paintForm, PaintTool paintTool, CanvasFactory canvasFactory, SaveControler saveControler, BitmapLoader bitmapLoader, Caretaker caretaker, OriginatorFactory originatorFactory) { _paintForm = paintForm; _paintCommand = PaintCommandFactory.GetPaintCommand(PaintToolType.Pencil); _paintForm.StartPaintAction += ExecuteStartPaintAction; _paintForm.StopPaintAction += ExecuteStopPaintAction; _paintForm.ToolAction += ExecuteToolAction; _paintForm.MovePaintAction += ExecuteMovePaintAction; _paintForm.ColorAction += ExecuteColorAction; _paintForm.SizePenAction += ExecuteSizePenAction; _paintForm.SizeChangeAction += ExecuteSizeChangeAction; _paintForm.SaveAction += ExecuteSaveAction; _paintForm.LoadAction += ExecuteLoadAction; _paintForm.RotateAction += ExecuteRotateAction; _paintForm.FlipAction += ExecuteFlipAction; _paintForm.UndoAction += ExecuteUndoAction; _paintForm.BrushAction += ExecuteBrushAction; _paintTool = paintTool; _saveControler = saveControler; _bitmapLoader = bitmapLoader; _currentCanvas = canvasFactory(400, 400); _temporaryCanvas = canvasFactory(400, 400); _caretaker = caretaker; _originator = originatorFactory(_currentCanvas.Bitmap, _currentCanvas.Width, _currentCanvas.Height); _originatorFactory = originatorFactory; }
public void Dispose() { if (BitmapLoader != null) { BitmapLoader.Dispose(); BitmapLoader = null; } GC.SuppressFinalize(this); }
Button CreateHexagonButton(int size, int id, float x, float y) { int hsize = (int)(0.85 * size); int vsize = (int)(0.9 * size); Rect bounds = new Rect(-hsize / 2, -vsize / 2, hsize / 2, vsize / 2); Bitmap bitmap = BitmapLoader.LoadAndResize(id, size, size); BitmapContent content = new BitmapContent(bitmap, null); return(new Button(content, bounds, pivot, x, y)); }
public static Texture[] AddTexture(string file, out int width, out int height) { if (sheetsLoaded) { throw new Exception($"Unable to add texture (file: {file}. Sheets are already loaded."); } var data = BitmapLoader.LoadTexture(file, out width, out height); return(new[] { addTexture(data, file, width, height) }); }
protected override async Task LoadImageAsync(string fileName) { Ready = false; var original = OriginalImage = await BitmapLoader.LoadGrayscale(fileName); AlteredImage = await Task.Run(() => { return(BitmapTransformer.ToBitmap(_Dither(BitmapTransformer.ToGrayscalePixelArray(original)))); }); Ready = true; }
/// <summary> /// キャラクタ情報を取得します /// </summary> /// <param name="c">文字</param> /// <returns>キャラクタ情報</returns> public FontBitmap GetCharacterBitmap(char c) { FontBitmap bmp; if (characterBitmapCache.TryGetValue(c, out bmp)) { return(bmp); } bmp = BitmapLoader.GetCharacterBitmap(c); characterBitmapCache[c] = bmp; return(bmp); }
private static Texture LoadBmp(string path) { var img = BitmapLoader.LoadFromFile(path); if (img == null) { return(null); } var ret = new Texture2D(img.Width, img.Height, TextureFormat.ARGB32, false); ret.SetPixels(img.Pixels); ret.Apply(); return(ret); }
Button CreateItem(int bitmap_id, string text, Rect bounds, float x, float y) { ComplexContent cc = new ComplexContent(null); int size = (int)(110 * GameView.scaleFactor); Bitmap bitmap = BitmapLoader.LoadAndResize(bitmap_id, size, size); BitmapContent bContent = new BitmapContent(bitmap, cc.pivot); TextContent tContent = new TextContent(text, ColorBank.Red, 50 * GameView.scaleFactor, cc.pivot, 0, 120 * GameView.scaleFactor); cc.contents.Add(bContent); cc.contents.Add(tContent); return(new Button(cc, bounds, pivot, x, y)); }
/// <summary> /// Initializes a new instance of the <see cref="RectangleMode"/> class. /// </summary> public GemsMode() { // Create a list of gem images. SceneNodeLinkedList <float> nodes = new SceneNodeLinkedList <float>(); RootSceneNode = nodes; // Create the blue gem. BitmapLoader systemLoader = new BitmapLoader(new FileInfo("Images/Gem Blue.png")); TextureLoader textureLoader = new TextureLoader(systemLoader); ImageNode <float> image = new ImageNode <float>(textureLoader); image.Point = new Point2 <float>(10, 10); image.DrawableRenderAnimators.Add( new DisappearingFlickerDrawableAnimation <float>()); image.DrawableRenderAnimators.Add( new UnsteadyFlickerDrawableAnimation <float>() { OpacityScale = 0.2, TimeScale = 1, }); Updating += image.OnUpdate; nodes.Add(image); // Create the green gem. systemLoader = new BitmapLoader(new FileInfo("Images/Gem Green.png")); textureLoader = new TextureLoader(systemLoader); image = new ImageNode <float>(textureLoader); image.Point = new Point2 <float>(60, 90); nodes.Add(image); // Create the translucent orange. systemLoader = new BitmapLoader(new FileInfo("Images/Gem Orange.png")); textureLoader = new TextureLoader(systemLoader); image = new ImageNode <float>(textureLoader); image.Tint = new Color <float>(0.5f, 1f, 1f, 1f); image.Point = new Point2 <float>(110, 10); nodes.Add(image); // Create an animated image. AnimatedImageNodeController <float> animatedController = new AnimatedImageNodeController <float>(); animatedController.NeedImageKey += OnLoadImageKey; animatedController.Load(new FileInfo("Images/Gem Animation.xml")); AnimatedImageNode <float> animatedImage = new AnimatedImageNode <float>(animatedController); animatedImage.Point = new Point2 <float>(10, 200); Updating += animatedImage.OnUpdate; nodes.Add(animatedImage); }
public Character(BinaryReader stream, short version) { _width = stream.ReadInt16(); _height = stream.ReadInt16(); stream.ReadBytes(28); int size = _width * _height * 4; BitmapLoader loader = new BitmapLoader(_width, _height); if (version >= 1) { _image = loader.LoadFromStream(stream, size); } loader.Close(); }
public void ApplyFilter(MainWindow mainWindow) { if (mainWindow.imageHandler != null) { List <byte> functionMapper = new List <byte>(); for (int i = 0; i < lines.Count; i++) { Line line = lines.ElementAt(i); int x0 = (int)line.X1; int y0 = 255 - (int)line.Y1; int x1 = (int)line.X2; int y1 = 255 - (int)line.Y2; int length = x1; if (i == lines.Count - 1) { length++; } for (int x = x0; x < length; x++) { double yDiff = y1 - y0; double xDiff = x1 - x0; int y; if (xDiff < 1) { y = y0; } else { double m = yDiff / xDiff; double diff = (x - x0); double d_y = y0 + diff * m; y = (int)d_y; } functionMapper.Add((byte)y); } } CustomFilter filter = new CustomFilter(functionMapper); mainWindow.imageHandler.ApplyFilter(image => filter.ApplyFilter(image)); mainWindow.filteredImage.Source = BitmapLoader.loadBitmap(mainWindow.imageHandler.getFiltered()); } }
public void ReadFromStream(BinaryReader stream) { // Read Header // string sign = new string(stream.ReadChars(4)); version = stream.ReadInt16(); short num_tiles = stream.ReadInt16(); SetTileSize(stream.ReadInt16(), stream.ReadInt16()); tile_bpp = stream.ReadInt16(); compression = stream.ReadByte(); has_obstructions = stream.ReadByte(); stream.ReadBytes(240); // data preallocated for the loop: int bit_size = tile_width * tile_height * (tile_bpp / 8); BitmapLoader loader = new BitmapLoader(tile_width, tile_height); Tile new_tile; while (num_tiles-- > 0) { new_tile = new Tile(tile_width, tile_height); new_tile.Graphic = loader.LoadFromStream(stream, bit_size); tiles.Add(new_tile); } // Read Tile Info Block: // foreach (Tile t in tiles) { stream.ReadByte(); t.Animated = stream.ReadBoolean(); t.NextAnim = stream.ReadInt16(); t.Delay = stream.ReadInt16(); stream.ReadByte(); t.Blocked = stream.ReadByte(); int segments = stream.ReadInt16(); int amt = stream.ReadInt16(); stream.ReadBytes(20); t.Name = new string(stream.ReadChars(amt)); while (segments-- > 0) { Line l = new Line(stream.ReadInt16(), stream.ReadInt16(), stream.ReadInt16(), stream.ReadInt16()); t.Obstructions.Add(l); } } loader.Close(); }
/// <summary> /// Loads a tileset from a filestream. /// </summary> /// <param name="reader">The System.IO.BinrayReader to use.</param> /// <returns>A tileset object.</returns> public static Tileset FromBinary(BinaryReader reader) { Tileset ts = new Tileset(); reader.ReadChars(4); // sign ts._version = reader.ReadInt16(); // version short numTiles = reader.ReadInt16(); ts.TileWidth = reader.ReadInt16(); ts.TileHeight = reader.ReadInt16(); reader.ReadInt16(); // tile_bpp ts._compression = reader.ReadByte(); ts._hasObstruct = reader.ReadByte(); reader.ReadBytes(240); using (BitmapLoader loader = new BitmapLoader(ts.TileWidth, ts.TileHeight)) { int bitSize = ts.TileWidth * ts.TileHeight * 4; while (numTiles-- > 0) { Tile newTile = new Tile(ts.TileWidth, ts.TileHeight); newTile.Graphic = loader.LoadFromStream(reader, bitSize); ts.Tiles.Add(newTile); } } foreach (Tile t in ts.Tiles) { reader.ReadByte(); t.Animated = reader.ReadBoolean(); t.NextAnim = reader.ReadInt16(); t.Delay = reader.ReadInt16(); reader.ReadByte(); t.Blocked = reader.ReadByte(); int segs = reader.ReadInt16(); int amt = reader.ReadInt16(); reader.ReadBytes(20); t.Name = new string(reader.ReadChars(amt)); while (segs-- > 0) { Line l = new Line(reader.ReadInt16(), reader.ReadInt16(), reader.ReadInt16(), reader.ReadInt16()); t.Obstructions.Add(l); } } return(ts); }
/// <summary> /// Initializes a new instance of the <see cref="RectangleMode"/> class. /// </summary> public GemsMode() { // Create a list of gem images. SceneNodeLinkedList<float> nodes = new SceneNodeLinkedList<float>(); RootSceneNode = nodes; // Create the blue gem. BitmapLoader systemLoader = new BitmapLoader(new FileInfo("Images/Gem Blue.png")); TextureLoader textureLoader = new TextureLoader(systemLoader); ImageNode<float> image = new ImageNode<float>(textureLoader); image.Point = new Point2<float>(10, 10); image.DrawableRenderAnimators.Add( new DisappearingFlickerDrawableAnimation<float>()); image.DrawableRenderAnimators.Add( new UnsteadyFlickerDrawableAnimation<float>() { OpacityScale = 0.2, TimeScale = 1, }); Updating += image.OnUpdate; nodes.Add(image); // Create the green gem. systemLoader = new BitmapLoader(new FileInfo("Images/Gem Green.png")); textureLoader = new TextureLoader(systemLoader); image = new ImageNode<float>(textureLoader); image.Point = new Point2<float>(60, 90); nodes.Add(image); // Create the translucent orange. systemLoader = new BitmapLoader(new FileInfo("Images/Gem Orange.png")); textureLoader = new TextureLoader(systemLoader); image = new ImageNode<float>(textureLoader); image.Tint = new Color<float>(0.5f, 1f, 1f, 1f); image.Point = new Point2<float>(110, 10); nodes.Add(image); // Create an animated image. AnimatedImageNodeController<float> animatedController = new AnimatedImageNodeController<float>(); animatedController.NeedImageKey += OnLoadImageKey; animatedController.Load(new FileInfo("Images/Gem Animation.xml")); AnimatedImageNode<float> animatedImage = new AnimatedImageNode<float>(animatedController); animatedImage.Point = new Point2<float>(10, 200); Updating += animatedImage.OnUpdate; nodes.Add(animatedImage); }
public DPFP.Template ConvertRawBmpAsTemplate(Bitmap RawBmp, DataPurpose ProcessPurpose = DataPurpose.Enrollment, short VertDpi = 700, short HorDpi = 700) { VariantConverter VConverter; Enroller = new DPFP.Processing.Enrollment(); RawBmp = EncodeBitmap(RawBmp, VertDpi, HorDpi); try { // converts raw image to dpSample using DFC 2.0--------------------------------------- // encode the bmp variable using the bitmap Loader BitmapLoader BmpLoader = new BitmapLoader(RawBmp, (int)RawBmp.HorizontalResolution, (int)RawBmp.VerticalResolution); BmpLoader.ProcessBitmap(); // return the required result inputData = BmpLoader.RawData; inpRaw = BmpLoader.DPInputParam; // dispose the object BmpLoader.Dispose(); // start the conversion process VConverter = new VariantConverter(VariantConverter.OutputType.dp_sample, DataType.RawSample, inpRaw, inputData, false); MemoryStream DStream = new MemoryStream(VConverter.Convert()); DPsample = new DPFP.Sample(DStream); // DPsample = DirectCast(VConverter.Convert(), DPFP.Sample) // converts dpSample to DPFeatures using the OTW''''''''''''''''''''''''''''''''''''''' DPFeatures = ExtractFeatures(DPsample, ProcessPurpose); // convert DPfeatures to ISO FMD using the DFC 2.0''''''''''''''''''''''''''''''''''''''' byte[] SerializedFeatures = null; DPFeatures.Serialize(ref SerializedFeatures); // serialized features into the array of bytes ISOFMD = DigitalPersona.Standards.Converter.Convert(SerializedFeatures, DigitalPersona.Standards.DataType.DPFeatureSet, DataType.ISOFeatureSet); // convert ISO FMD to DPTemplate using DFC 2.0''''''''''''''''''''''''''''''''''''''' byte[] DPTemplateData = DigitalPersona.Standards.Converter.Convert(ISOFMD, DigitalPersona.Standards.DataType.ISOTemplate, DataType.DPTemplate); // deserialize data to Template DPTemplate = new DPFP.Template(); DPTemplate.DeSerialize(DPTemplateData); // required for database purpose // ============================================================================ DStream.Close(); return(DPTemplate); } catch (Exception ex) { return(null /* TODO Change to default(_) if this is not a reference type */); } }
Button CreateDifficultyButton(int res_id, string text, float x, float y) { int size = (int)(128 * GameView.scaleFactor); Bitmap b = BitmapLoader.LoadAndResize(res_id, size, size); BitmapContent bc = new BitmapContent(b, null, 0, 0); TextContent tc = new TextContent(text, ColorBank.Red, 44 * GameView.scaleFactor, null, 0, 110 * GameView.scaleFactor); ComplexContent cc = new ComplexContent(null, 0, 0); cc.contents.Add(bc); cc.contents.Add(tc); int h = (int)(100 * GameView.scaleFactor); int vup = (int)(-90 * GameView.scaleFactor); int vdown = (int)(150 * GameView.scaleFactor); Rect bounds = new Rect(-h, vup, h, vdown); return(new Button(cc, bounds, pivot, x, y)); }
public static Texture[] AddSprite(string file, int width, int height) { if (sheetsLoaded) { throw new Exception($"Unable to add texture (file: {file}. Sheets are already loaded."); } var dataList = BitmapLoader.LoadSprite(file, width, height); var textures = new Texture[dataList.Count]; for (int i = 0; i < dataList.Count; i++) { textures[i] = addTexture(dataList[i], file, width, height); } return(textures); }
protected override void OnLoad() { Console.Write("Loading..."); base.OnLoad(); KeyInput.SetWindow(this); MouseInput.SetWindow(this); // Load icon var iconData = BitmapLoader.LoadBytes(FileExplorer.FindIn(FileExplorer.Misc, "warsnu"), out var iconWidth, out var iconHeight); Icon = new WindowIcon(new Image(iconWidth, iconHeight, iconData)); MasterRenderer.Initialize(); SheetManager.InitSheets(); timer.Restart(); FontManager.Load(); timer.StopAndWrite("Loading Fonts"); timer.Restart(); AudioController.Load(); MusicController.Load(); timer.StopAndWrite("Loading Sound"); timer.Restart(); GameController.Load(); timer.StopAndWrite("Loading Rules"); SheetManager.FinishSheets(); MasterRenderer.InitRenderer(); GameController.CreateFirst(); Ready = true; Console.WriteLine(" Done!"); if (Program.OnlyLoad) { Program.Exit(); } }
public override Java.Lang.Object InstantiateItem(ViewGroup container, int position) { PhotoView photoView = new PhotoView(true, curentContext); photoView.SetScaleType(ImageView.ScaleType.CenterCrop); photoView.Tag = position; string path = mPathList[position]; if (path != null) { if (mCache.Get(path) is Android.Graphics.Bitmap bitmap) { photoView.SetImageBitmap(bitmap); } else { if (System.IO.File.Exists(path)) { bitmap = BitmapLoader.GetBitmapFromFile(path, mWidth, mHeight); if (bitmap != null) { photoView.SetImageBitmap(bitmap); mCache.Put(path, bitmap); } else { photoView.SetImageResource(Resource.Drawable.aurora_picture_not_found); } } else { photoView.SetImageResource(Resource.Drawable.aurora_picture_not_found); } } } else { photoView.SetImageResource(Resource.Drawable.aurora_picture_not_found); } container.AddView(photoView, ViewGroup.LayoutParams.MatchParent, ViewGroup.LayoutParams.MatchParent); return(photoView); }
// Methods public override void LoadContent(ContentManager content) { background = new Background( new Sprite(content, "B1011-1", new Vector2(-500, -300), 4.2f), new List <Sprite>() { new Sprite(content, "M1011", new Vector2(50, -100), 0.2f) }, new List <Sprite>(), new List <Vector2>() ); entities = new List <Entity>(); terrainLoader = new BitmapLoader(PlatformerJarno.Properties.Resources.lvl1); terrain = terrainLoader.GetTerrain(content); entities.Add(new Enemy(content, "slime_spritesheet", new Vector2(540, 80), entities, terrain, bullets)); entities.Add(new Enemy(content, "slime_spritesheet", new Vector2(660, 80), entities, terrain, bullets)); player = new Player(content, "player_spritesheet", new Vector2(0, 0), entities, terrain, bullets); portal = new Portal(content, "portal_spritesheet", new Vector2(960, 140)); collision = new Collision(terrain, entities, bullets); }
private void JpgButton_Click(object sender, RoutedEventArgs e) { try { var dialog = new SaveFileDialog { Filter = "Jpg files (*.jpg)|*.jpg|All files|*.*" }; if (dialog.ShowDialog() == true) { BitmapLoader.Save2Jpg( BitmapLoader.SaveImageSource(ItemsControl, (int)ItemsControl.Width, (int)ItemsControl.Height), dialog.FileName); } } catch (Exception exception) { this.ShowMessageAsync("Save error", exception.Message); Log.Error("Save error", exception); } }
// Methods public override void LoadContent(ContentManager content) { background = new Background( new Sprite(content, "bg_lvl2", new Vector2(-250, -90), 1f), new List <Sprite>(), new List <Sprite>(), new List <Vector2>() ); entities = new List <Entity>(); terrainLoader = new BitmapLoader(PlatformerJarno.Properties.Resources.lvl2); terrain = terrainLoader.GetTerrain(content); portal = new Portal(content, "portal_spritesheet", new Vector2(380, 420)); entities.Add(new Enemy(content, "slime_spritesheet", new Vector2(240, 20), entities, terrain, bullets)); entities.Add(new Enemy(content, "slime_spritesheet", new Vector2(540, 240), entities, terrain, bullets)); entities.Add(new Enemy(content, "slime_spritesheet", new Vector2(360, 200), entities, terrain, bullets)); entities.Add(new Enemy(content, "slime_spritesheet", new Vector2(140, 300), entities, terrain, bullets)); player = new Player(content, "player_spritesheet", new Vector2(20, 20), entities, terrain, bullets); collision = new Collision(terrain, entities, bullets); }
private void InitCurrentItem() { PhotoView photoView = new PhotoView(true, this); string msgId = Intent.GetStringExtra("msgId"); int position = mMsgIdList.IndexOf(msgId); string path = mPathList[position]; if (path != null) { if (mCache.Get(path) is Android.Graphics.Bitmap bitmap) { photoView.SetImageBitmap(bitmap); } else { if (System.IO.File.Exists(path)) { bitmap = BitmapLoader.GetBitmapFromFile(path, mWidth, mHeight); if (bitmap != null) { photoView.SetImageBitmap(bitmap); mCache.Put(path, bitmap); } else { photoView.SetImageResource(Resource.Drawable.aurora_picture_not_found); } } else { photoView.SetImageResource(Resource.Drawable.aurora_picture_not_found); } } } else { photoView.SetImageResource(Resource.Drawable.aurora_picture_not_found); } mViewPager.CurrentItem = position; }
public ChoiceScene() : base() { linePaint = new Paint(); linePaint.Color = ColorBank.GetColor(ColorBank.Red); linePaint.StrokeWidth = 6 * GameView.scaleFactor; lineLR = 308 * GameView.scaleFactor; lineX = 80 * GameView.scaleFactor; Rect bounds = new Rect((int)(-310 * GameView.scaleFactor), (int)(-90 * GameView.scaleFactor), (int)(310 * GameView.scaleFactor), (int)(235 * GameView.scaleFactor)); spButton = CreateItem(Resource.Drawable.choice_singleplayer, "SINGLEPLAYER", bounds, 0, -170 * GameView.scaleFactor); spButton.Pressed += () => { Hide(Side.Left); SingleGameRunupScene.Instance.Show(Side.Right); }; bounds = new Rect(bounds); bounds.Top = (int)(-130 * GameView.scaleFactor); mpButton = CreateItem(Resource.Drawable.choice_multiplayer, "MULTIPLAYER", bounds, 0, 240 * GameView.scaleFactor); int size = (int)(90 * GameView.scaleFactor); Bitmap backBitmap = BitmapLoader.LoadAndResize(Resource.Drawable.back, size, size); BitmapContent backContent = new BitmapContent(backBitmap, null); int hb = (int)(80 * GameView.scaleFactor); backButton = new Button(backContent, new Rect(-hb, -hb, hb, hb), pivot, -265 * GameView.scaleFactor, -380 * GameView.scaleFactor); backButton.Pressed += () => { MenuScene.Instance.Show(Side.Left); Hide(Side.Right); }; }