bitmapimage

Bitmap.getWidth()' on a null object reference

坚强是说给别人听的谎言 提交于 2019-12-24 09:07:49
问题 I just got into this problem on the line CreateScaledBitmap, I am trying to set this image as device's wallpaper and I need to scale this image to the device, thats why I am doing this method but unfortunately I cant fix this Bitmap width() error setWall.setOnClickListener(new View.OnClickListener() { @RequiresApi(api = Build.VERSION_CODES.KITKAT) @Override public void onClick(View view) { Picasso.with(getApplicationContext()).load(imageBrought).into(new Target() { @Override public void

How to render a large items listview into RenderTargetBitmap?

风流意气都作罢 提交于 2019-12-24 08:11:55
问题 I'm trying to render a list view using RenderTargetBitmap. The code below only renders one page. It doesn't add pages to the downloaded pdf according to the list view. This code takes snapshot of what is shown on the page but not whole list. I followed this link: XAML To PDF Conversion This is my code behind file: using Syncfusion.Pdf; using Syncfusion.Pdf.Graphics; using System; using System.Collections.Generic; using System.Drawing; using System.IO; using System.Linq; using System.Runtime

loading the source of a BitmapImage in WPF?

梦想的初衷 提交于 2019-12-24 01:54:19
问题 In a silverlight app, I have a BitmapImage defined as System.Windows.Media.Imaging.BitmapImage and it as a method called " SetSource " where I can set the source like this: BitmapImage bitmap = new BitmapImage(); System.IO.Stream stream = _scene.GetStream(); if (stream == null) return; bitmap.SetSource(stream); In a WPF application I have also have a Bitmap image defined as System.Windows.Media.Imaging.BitmapImage but there is no SetSource method. How do I set the source in a WPF app like I

Creating a CroppedBitmap at runtime - won't load from resource

亡梦爱人 提交于 2019-12-23 20:27:01
问题 I'm trying to write code that will load an image from a resource, and then crop it. This code works when I do all, or part, of it in XAML. I want to switch from all-XAML to all-code, so I can reuse this more than one place, with different Uris. But when I try to do the same thing in code, I get a DirectoryNotFoundException, because suddenly it starts trying to look for a folder on disk, instead of loading the image from the resource. If I load the BitmapImage in XAML, and then create a

BitmapImage returns 0 for PixelWidth and PixelHeight

时间秒杀一切 提交于 2019-12-23 08:13:25
问题 I'm trying to do a super simple thing : get the size of an image. So I create my BitmapImage but I'm getting 0 when I try to access the PixelWidth and PixelHeight . How can I accomplish that please? EDIT: (added sample code) I'm just doing: var baseUri = new Uri("ms-appx:///"); var bitmapImage = new BitmapImage(new Uri(baseUri, "Assets/Logo.png")); MyImage.Source = bitmapImage; Debug.WriteLine("Width: " + bitmapImage.PixelWidth + " Height: " + bitmapImage.PixelHeight); In the console, I get:

BitmapImage returns 0 for PixelWidth and PixelHeight

南楼画角 提交于 2019-12-23 08:12:04
问题 I'm trying to do a super simple thing : get the size of an image. So I create my BitmapImage but I'm getting 0 when I try to access the PixelWidth and PixelHeight . How can I accomplish that please? EDIT: (added sample code) I'm just doing: var baseUri = new Uri("ms-appx:///"); var bitmapImage = new BitmapImage(new Uri(baseUri, "Assets/Logo.png")); MyImage.Source = bitmapImage; Debug.WriteLine("Width: " + bitmapImage.PixelWidth + " Height: " + bitmapImage.PixelHeight); In the console, I get:

C# how to get a bitmap from a picturebox

雨燕双飞 提交于 2019-12-23 07:51:50
问题 I have a image in picturebox. I want to get that image as a Bitmap. My one line code is: Bitmap default_image = (Bitmap)pictureBox5.Image.Clone(); But what i am getting is: default_image value=null; Can anyone help me. 回答1: Bitmap default_image = new Bitmap(pictureBox5.Image); You are never instantiating a Bitmap which is why it is null . 回答2: If you got the image into the PictureBox by using imageLocation pbSourceImage.ImageLocation = openFile.FileName; then PictureBox.Image will be null.

Need to send Image to server in android?

♀尐吖头ヾ 提交于 2019-12-23 05:08:36
问题 Need to send capture image to server in android, Image I am sending is in string, code for same: ByteArrayOutputStream baos = new ByteArrayOutputStream(); myBitmap.compress(Bitmap.CompressFormat.JPEG, 100, baos); byte[] byteArray = baos.toByteArray(); String strBase64 = Base64.encodeToString(byteArray, Base64.DEFAULT); Problem i am facing is strBase64 length is too large, code to send image is : private boolean post(Context context, String message) { HttpURLConnection urlConnection = null;

accessing image files from a separated assembly

落花浮王杯 提交于 2019-12-23 03:44:27
问题 I have several image files I want to share between projects(common icons) I have them in an assembly that would be in every solution I create...I have the files in a folder called Icon and I have the build as content copy always. I have verified that a folder is created with these icons...however my other assemblies are not able to find them... <r:RibbonGroup Header="Users"> <r:RibbonButton > <r:RibbonButton.LargeImageSource> <BitmapImage UriSource="..\Icons\UserIcon.png" /> </r:RibbonButton

Convert an XAML file to a BitmapImage

*爱你&永不变心* 提交于 2019-12-23 01:16:29
问题 I want to create a BitmapImage with a desired resolution from an XAML (text) file. how can I do that? thanks. 回答1: To load your Xaml file: Stream s = File.OpenRead("yourfile.xaml"); Control control = (Control)XamlReader.Load(s); And creating the BitmapImage: public static void SaveImage(Control control, string path) { using (MemoryStream stream = new MemoryStream()) { GenerateImage(element, stream); Image img = Image.FromStream(stream); img.Save(path); } } public static void GenerateImage