Skip to main content

All Questions

Tagged with
Filter by
Sorted by
Tagged with
0 votes
1 answer
194 views

Converting System.Drawing.Bitmap to a ImageSource memory stream to insert into a PdfSharpCore PdfDocument under Linux

I'm creating a barcode using DataMatrix.NetCore nuget package. I'm attempting to get that inserted into a PDF using PdfSharpCore. The barcode is generated and a bitmap is created, but the conversion ...
Robb Sadler's user avatar
0 votes
0 answers
46 views

System.NotSupportedException on EndInit() after conversion to Bitmap from ByteArray

I select an image, apply some effects to pixels, then try to display it to the right of the original image. It's done via MemoryStream. Upon converting the array of bytes that contains processed ...
Лев Поваляев's user avatar
0 votes
1 answer
207 views

"Parameter is invalid" when saving Bitmap to MemoryStream

I have an array of bitmaps which need compiling into a single, multi-page tiff image, however when saving the bitmap to a MemoryStream object I get the "Parameter is invalid" error message ...
Jake Davison's user avatar
0 votes
0 answers
270 views

base64 string image been rotated in excel document c#

i have an excel document in which images get added on to. Some of my images loads correctly and some of them are been rotated on it own. this is part of my code if (!base64Image.IsNullOrEmpty()) ...
deanpillow's user avatar
0 votes
1 answer
517 views

Bitmap.Save erroring with Null Exception and yet it is clearly instantiated

Before an upgrade to Unity and Visual Studio I had a simple block of code that ran without errors, after the updates however the exact same logic raises a NullReferenceException. The exception is ...
CodeMonkey's user avatar
  • 1,835
1 vote
1 answer
3k views

Convert PDF to Image Byte array to save to database

What I am trying to accomplish is allowing my user to upload a PDF. I will then convert that to an Image and get the Images byte array. Below is what I have so far. PdfDocumentProcessor ...
Eric's user avatar
  • 258
0 votes
1 answer
399 views

ArgumentException: Parameter is not valid while copying from FileStream to MemoryStream

I am trying to resize image using bitmap from Memorystream and save to directory. It works on the first run but if i try to update the image second time i am getting ArgumentException. public ...
MADMAX's user avatar
  • 160
0 votes
0 answers
935 views

How to compress a bitmap in c#

I have a code that takes a screenshot and I need to compress it in order to send it. The following code converts a Bitmap into a stream and compresses it. My problem is that the compression outcome is ...
Anna's user avatar
  • 1
0 votes
0 answers
148 views

Low quality bitmap copy of original bitmap becomes larger after lowering the quality

I am trying to create copies of an original image that is of lower quality than the original. And everything works with jpeg. When working with bmp though - with the lowest quality I can set: 0. The ...
lolelo's user avatar
  • 740
0 votes
1 answer
327 views

VB.net DownloadDataAsync to MemoryStream not working

I have the following code to load a picture from the internet directly into my picturebox (from memory): PictureBox1.Image = New Bitmap(New IO.MemoryStream(New Net.WebClient().DownloadData("LINK"))) ...
2zoo's user avatar
  • 47
2 votes
1 answer
5k views

Saving Bitmap to MemoryStream

I am trying to save a bitmap to a MemoryStream and then convert it to string. But the problem is, I am having an error that says the line img.Save(m, img.RawFormat); cannot be null. The error is this ...
Ghoenn Woods's user avatar
-1 votes
2 answers
244 views

Bitmap throwing exception while read from MemoryStream using ms access [duplicate]

Im retrieving pictures from database, i want to display it to picturebox. getting exception "Not a valid parameter" i already google it, and almost of it not solve my problem. while (reader.Read()) {...
Dodong's user avatar
  • 39
1 vote
1 answer
786 views

MemoryStream uses too much memory and doesn't dispose/close

The memory usage goes up until it hits System.OutOfMemory exception. The MemoryStream instances count goes up until exception as well. I tried using using(), doing ms.Dispose(), ms.Close(), few other ...
Tester12323323's user avatar
0 votes
2 answers
1k views

c# cannot use memory stream to convert byte array to bitmap

I have been looking for days now and all the current answers on how to convert a byte[] filled with imageData leads me back to this piece of code: using (var ms = new MemoryStream(byte[])) { ...
Tanya Dørr Holst's user avatar
-1 votes
2 answers
1k views

Issue Converting Bytes to an Image from a PDF file

I am trying to convert a pdf file to a Bitmap by first getting the Bytes of the PDF file and then converting it into a MemoryStream to Be converted into the Bitmap. This worked successfully when ...
Seamus's user avatar
  • 11
1 vote
0 answers
622 views

Back color changed to black while converting a bitmap to memorystream and then back to Bitmap

I face an issue. I am trying to convert the Bitmap image into a memoryStream and store it. When converting the memoryStream back to image the background is becoming black ms = new MemoryStream(); frm....
Anjana manoharan's user avatar
0 votes
0 answers
422 views

WCF: using memorystream to transfer bitmaps in C#

I am using WCF for communication between client and server program on the same machine. Earlier I used Bitmaps to transfer video frames to the client. It was successful with WCF, but I only have 6 ...
user4576528's user avatar
0 votes
0 answers
338 views

Memorystream - OutOfMemoryException

It might be that this question has been answered before, but I found no good solution to my problem. I am trying to convert a Bitmap to a bytearray using a memory stream, but when I do so I get an ...
Philip Johan Brun's user avatar
0 votes
1 answer
784 views

C# Bitmap Image - Exception : Parameter is not valid

I try to work with Image. It worked well but sometimes I got “Parameter is not valid” exception. I don't know why that problem occurs, please help me: byte[] img = (byte[])PatientData.Rows[index - 1][...
Tin Chip's user avatar
  • 135
0 votes
1 answer
257 views

Keeping MemoryStream open or clone image

I'm reading images from a database. I read the binary / blob for a field, and I convert it to an image like this: Public Function BytesToImage(ByVal ByteArr() As Byte) As Image If ByteArr....
tmighty's user avatar
  • 11.3k
0 votes
0 answers
44 views

Bitmap A generic error or parameter is not valid [duplicate]

I have a fallowing method which raises exceptions depending on stream size. I have a feeling that the problem is memory limits. Can someone explain me why i get those errors and how to fix this? ...
Norbertas Brazaitis's user avatar
0 votes
0 answers
44 views

Exception message when using MemoryStream to an Array [duplicate]

I keep getting an exception message Value Cannot Be Null Parameter name : Encoder Which seems to be triggered by the line starting "picture Box3.Image.Save(ms...." etc. I am using ...
Steve Galvin's user avatar
0 votes
0 answers
622 views

C# : Get Source of Image from Memory over Bitmap and BitmapImage

-I am trying to write a method for a Card Scanner and I am quite new in C# :) -The application I wrote can scan and gets the images from the Scanner, but I can not show them on the WPF. -The SDK is ...
A. Cinar's user avatar
3 votes
1 answer
2k views

How to convert System.Windows.Media.DrawingImage into Stream?

I'am trying convert DrawingImage into MemoryStream. My code looks like this: public MemoryStream ImageStream(DrawingImage drawingImage) { MemoryStream stream = new MemoryStream(); ...
Shagohad's user avatar
  • 395
0 votes
1 answer
1k views

Image data loss when converting to byte array

I'm trying to use a MemoryStream to turn an image into a byte array, however, the image looks different when I recover it. I made a simple Form app to show the issue. I'm using the google chrome Icon ...
flakes's user avatar
  • 23.5k
1 vote
1 answer
3k views

Parameter is not valid. Stack Trace at System.Drawing.Bitmap..ctor(Stream stream)

For some cases only i'm getting this error. "Parameter is not valid Stack Trace at System.Drawing.Bitmap..ctor(Stream stream)" i am little confused how it is working for some records why not for ...
shobia's user avatar
  • 75
0 votes
0 answers
142 views

Convert Base64 from PDF to Bitmap [duplicate]

I would like to convert a PDF to a Bitmap, so I can show it on my ASP.NET page. But when I run my code it fails at creating the Bitmap. Does anyone know what's the problem? string filepath = "C:\\...
sarah's user avatar
  • 9
6 votes
2 answers
6k views

Reduce image size in C#

I want function which will reduce image size. The function should take the image URL, check is image 4MB size or bigger and if it is then resize it to lover then 4MB and return bytes. I have next ...
carpics's user avatar
  • 2,282
1 vote
1 answer
2k views

Bitmap.Save() method is not working in Unity source

I wanna implement 'Bitmap to Texture2D' function in Unity. I learned to make Texture2D instance, use this syntax below. // **LoadImage(byte[] arr)** can load byte array data and make Texture2D var ...
FragrantJH's user avatar
0 votes
0 answers
870 views

C# Bitmap / MemoryStream lock issue

I have presumably tried over 15 different techniques to convert a TIFF to a Bitmap, yet all already succed with a 99% chance. In 1% of all cases the Bitmap will be locked and I will face an Exception ...
Nex's user avatar
  • 429
3 votes
3 answers
7k views

How to insert a dynamically generated bitmap into PDF document using PDFsharp?

I am trying to use PDFsharp to insert a dynamically generated bitmap of a QR Code in to a PDF document. I don't want to save the bitmap to the file but just want to insert it into the PDF. The ...
user2789697's user avatar
0 votes
1 answer
1k views

Parameter is not valid when using MemoryStream

I'm making some Bitmap image manipulation application in c# so I need to implicitly convert image to bmp so I can manipulate it like byte[] (byte array). Problem appears when this image is not bmp ...
user3647695's user avatar
3 votes
1 answer
3k views

argumentnullexception bitmap save to memorystream

I'm trying to save my Bitmap to MemoryStream - what wrong in this code? Why it gets me argumentnullexception ?? private void insertBarCodesToPDF(Bitmap barcode) { ....... ...
whizzzkey's user avatar
  • 946
1 vote
1 answer
395 views

parameter not valid at saving bitmap

I'm resizing an image using the following code: private void ResizeImage(string path) { var maxWidth = 700; var ms = new MemoryStream(System.IO.File.ReadAllBytes(Server.MapPath(...
arash moeen's user avatar
  • 4,673
0 votes
2 answers
2k views

Size of bitmap byte[] differs from BMP memorystream size

I´m trying to send a bitmap over a tcp/ip connection. So far my programm works as it should. But during debugging I discovered a strange value of my bitmap byte[]. I open a 24bit bitmap and convert ...
royalTS's user avatar
  • 631
2 votes
0 answers
3k views

ASP.NET [ExternalException (0x80004005): A generic error occurred in GDI+.] at bitmap.Save(MStream, ImageFormat.Tiff)

I've read hundreds of "A generic error occurred in GDI+" posts and can't quite get the issue straightened out. I'm trying to insert a page and then apply some text to each page of a multi-page tiff. ...
user3799279's user avatar
2 votes
2 answers
2k views

Loading saved byte array to memory stream causes out of memory exception

At some point in my program the user selects a bitmap to use as the background image of a Panel object. When the user does this, the program immediately draws the panel with the background image and ...
user2320861's user avatar
  • 1,431
-3 votes
2 answers
861 views

Memory out of Exception while creating Bitmap from MemoryStream in WinCE Device

using (MemoryStream ms = imager.CaptureImageNow().MemoryStream ) { using (Bitmap bmp = new Bitmap(ms)) // Memory Out of Exception occurs here { this.PreviewImage( bmp ); } } Hi ,...
user3042169's user avatar
0 votes
0 answers
601 views

new Bitmap(MemoryStream ms) returns upside-down image

I have two byte[] - representations of bitmap - one from bitmap.save(ms), ms.toarray, and the other from a bunch of other functions. According to my eyes that witnessed output of Watch windows, these ...
Dantragof's user avatar
  • 155
0 votes
1 answer
793 views

how to write byte[] to Image with Landscape or Portrait properties?

I have a code which converts byte[] to image but my code always writes in Landscape mode even original image was Portrait. How can I detect original image's Page Orientation and write new Image with ...
cihadakt's user avatar
  • 3,204
0 votes
2 answers
3k views

C# MemoryStream slowing programme performance

I'm working on a project using WPF to display the Kinect ColorImageFrame and a skeleton representation. I also have to record those two videos. I'm able to display and record (using EmguCV) those two ...
Florent Gz's user avatar
2 votes
2 answers
776 views

Cropping Centre of Image Stored In A MemoryStream

I have an image upload form that stores two sizes of images: Large and Thumbnail image. For the thumbnail image, I am trying to crop image from the center and re-size to: 30px x 30px. Here is my ...
SurinderBhomra's user avatar
1 vote
1 answer
462 views

System.ArgumentException at System.Drawing.ImageFromStream

Ok, so I've seen multiple people with this issue, and I've found to some extent what might be causing the issue, but I can't figure out how to fix it. Basically, I'm trying to send a screenshot from a ...
user1742916's user avatar
4 votes
1 answer
3k views

A generic error occurred in GDI+ when I saving png to MemoryStream in IIS7

I have an error when I try save png to memory stream. On my ASP.NET Development Server everything works but when I run site under IIS7 - there are generated an error. Also when I try saving jpg format ...
Victoria's user avatar
  • 175
1 vote
2 answers
2k views

No transparency in Bitmap when loading from MemoryStream

When I am writing a Bitmap to a file and read from the file, I am getting the transparency correctly. using (Bitmap bmp = new Bitmap(2, 2)) { Color col = Color.FromArgb(1, 2, 3, 4); bmp....
Jogi Joseph George's user avatar
2 votes
1 answer
2k views

Image crop not working correctly

The snippet of code is supposed to crop an image, however the size of the crop is correct, but the crop starts at the top left corner. These images illustrate the problem more clearly and . The co-...
Lee's user avatar
  • 8,724
4 votes
3 answers
4k views

Why is there a memory leak when I do not .Dispose() Bitmaps that I .Save() to a MemoryStream?

Say I create a Bitmap Bitmap bitmap = new Bitmap(320, 200); When I write it to some stream (in my case, it's a HttpResponseStream, as given out by HttpListenerResponse), everything is fine: bitmap....
Evgeniy Berezovsky's user avatar
41 votes
2 answers
101k views

Saving a bitmap into a MemoryStream

Should I allocate the memory or just the object of the memory stream: Is this OK? MemoryStream memoryStream = new MemoryStream(); bitmap.Save(memoryStream, System.Drawing.Imaging.ImageFormat.Jpeg); ...
Joseph's user avatar
  • 1,774
2 votes
1 answer
3k views

A generic error occurred in GDI+ exception when trying to save image into MemoryStream

I am using C# windows form. My code : private void Openbutton_Click(object sender, EventArgs e) { OpenFileDialog openFileDialog = new OpenFileDialog(); if (openFileDialog.ShowDialog()...
JatSing's user avatar
  • 4,967
0 votes
2 answers
1k views

Converting Bitmap to Binary Array performance

I do have a Bitmap Array that contains more than 500 Bitmaps object. I need to convert each single Bitmap object within the Array into a binary Array. I'm using the MemoryStream class to achieve this: ...
Michael Hidalgo's user avatar