bitmapimage

InteropBitmap to BitmapImage

我们两清 提交于 2019-12-01 17:49:28
I'm trying to Convert a Bitmap (SystemIcons.Question) to a BitmapImage so I can use it in a WPF Image control. I have the following method to convert it to a BitmapSource , but it returns an InteropBitmapImage , now the problem is how to convert it to a BitmapImage . A direct cast does not seem to work. Does anybody know how to do it? CODE: public BitmapSource ConvertToBitmapSource() { int width = SystemIcons.Question.Width; int height = SystemIcons.Question.Height; object a = System.Windows.Interop.Imaging.CreateBitmapSourceFromHBitmap(SystemIcons.Question.ToBitmap().GetHbitmap(), IntPtr.Zero

InteropBitmap to BitmapImage

▼魔方 西西 提交于 2019-12-01 17:19:31
问题 I'm trying to Convert a Bitmap (SystemIcons.Question) to a BitmapImage so I can use it in a WPF Image control. I have the following method to convert it to a BitmapSource , but it returns an InteropBitmapImage , now the problem is how to convert it to a BitmapImage . A direct cast does not seem to work. Does anybody know how to do it? CODE: public BitmapSource ConvertToBitmapSource() { int width = SystemIcons.Question.Width; int height = SystemIcons.Question.Height; object a = System.Windows

Creating 8bpp bitmap with GDI and saving it as a file

点点圈 提交于 2019-12-01 10:56:01
I have a perfectly working code that creates 32bpp bitmap and I need to change it so that 8bpp bitmap is created. Here's the piece of code that creates 32bpp bitmap, draws into it, then it creates a bitmap file and store it into the vector of bytes: // prepare bitmap: BYTE* bitmap_data = NULL; HDC hDC = GetDC(NULL); HDC memHDC = CreateCompatibleDC(hDC); BITMAPINFO bmi; memset(&bmi, 0, sizeof(BITMAPINFO)); bmi.bmiHeader.biSize = sizeof(BITMAPINFOHEADER); bmi.bmiHeader.biWidth = desiredWidth; // desiredWidth is 800 bmi.bmiHeader.biHeight = desiredHeight; // desiredHeight is 202 bmi.bmiHeader

Rotate a BitmapImage

a 夏天 提交于 2019-12-01 09:16:57
I want to rotate a bitmap image I wrote some code and it work TransformedBitmap TempImage = new TransformedBitmap(); TempImage.BeginInit(); TempImage.Source = MyImageSource; // MyImageSource of type BitmapImage RotateTransform transform = new RotateTransform(90); TempImage.Transform = transform; TempImage.EndInit(); image1.Source = TempImage; but I want that MyImageSource get this modification, because like that if I click again in the button nothing happen and this normal it get the first form of my image, and also I want it to take this form because I have to save it after modification. why

Creating a BitmapImage WPF

試著忘記壹切 提交于 2019-12-01 08:09:03
I have a ushort[] containing image data I need to display on screen, at the minute I am creating a Windows.System.Drawing.Bitmap, and converting this to a BitmapImage but this feels like a slow inneficent way to do this. Does anyone what the fastest way to create a BitmapImage of a ushort[] is? or alternativly create an ImageSource object from the data? Thanks, Eamonn My previous method for converting Bitmap to BitmapImage was: MemoryStream ms = new MemoryStream(); bitmap.Save(ms, ImageFormat.Png); ms.Position = 0; BitmapImage bi = new BitmapImage(); bi.BeginInit(); bi.StreamSource = ms; bi

Creating a BitmapImage WPF

早过忘川 提交于 2019-12-01 06:08:11
问题 I have a ushort[] containing image data I need to display on screen, at the minute I am creating a Windows.System.Drawing.Bitmap, and converting this to a BitmapImage but this feels like a slow inneficent way to do this. Does anyone what the fastest way to create a BitmapImage of a ushort[] is? or alternativly create an ImageSource object from the data? Thanks, Eamonn 回答1: My previous method for converting Bitmap to BitmapImage was: MemoryStream ms = new MemoryStream(); bitmap.Save(ms,

C# Load JPG file, extract BitmapImage

我们两清 提交于 2019-12-01 02:45:37
I am trying to extract a BitmapImage from a JPG. This is the code I have: FileStream fIn = new FileStream(sourceFileName, FileMode.Open); // source JPG Bitmap dImg = new Bitmap(fIn); MemoryStream ms = new MemoryStream(); dImg.Save(ms, ImageFormat.Jpeg); image = new BitmapImage(); image.BeginInit(); image.StreamSource = new MemoryStream(ms.ToArray()); image.EndInit(); ms.Close(); image comes back with a 0 × 0 image, which of course means it didn't work. How do I do this? Try this: public void Load(string fileName) { using(Stream BitmapStream = System.IO.File.Open(fileName,System.IO.FileMode

Convert DrawingImage to BitmapImage

爱⌒轻易说出口 提交于 2019-12-01 01:49:11
I want to draw large number of shapes (lines, ellipses and ...) and then save them as bitmap or png. I made the drawings and the question is: how can I convert a DrawingImage to BitmapImage in C#? the code is something like this: DrawingGroup drawingGroup = new DrawingGroup(); using(DrawingContext context = drawingGroup.Open()) { //make some drawing } DrawingImage drawingImage = new DrawingImage(drawingGroup) // your suggestion? DrawingImage - > BitmapImage You may put the ImageDrawing into an Image control and render that into a RenderTargetBitmap , which is a BitmapSource and can therefore

Convert DrawingImage to BitmapImage

假如想象 提交于 2019-11-30 20:58:18
问题 I want to draw large number of shapes (lines, ellipses and ...) and then save them as bitmap or png. I made the drawings and the question is: how can I convert a DrawingImage to BitmapImage in C#? the code is something like this: DrawingGroup drawingGroup = new DrawingGroup(); using(DrawingContext context = drawingGroup.Open()) { //make some drawing } DrawingImage drawingImage = new DrawingImage(drawingGroup) // your suggestion? DrawingImage - > BitmapImage 回答1: You may put the ImageDrawing

BitmapImage size restrictions in Silverlight

ⅰ亾dé卋堺 提交于 2019-11-30 19:36:04
问题 I'm making a Windows Phone 7 application which involves getting large images from the web and putting it in a ScrollViewer for the user to scroll through. I think I'm hitting a limitation of BitmapImage , though, as the image seems to get cut off at 2048 pixels in either height or width. Is this a known limitation of Silverlight BitmapImage and is there some other class to use in this case to allow scrolling through the large images? Thanks 回答1: Yes, there is a limit of 2k x 2k. This is