Click here to Skip to main content
15,172,297 members
Home / Discussions / C#
   

C#

 
QuestionRead from process Pin
thomaxz.tc13-Jun-09 10:37
Memberthomaxz.tc13-Jun-09 10:37 
AnswerRe: Read from process Pin
Luc Pattyn13-Jun-09 11:12
sitebuilderLuc Pattyn13-Jun-09 11:12 
GeneralRe: Read from process Pin
thomaxz.tc13-Jun-09 13:29
Memberthomaxz.tc13-Jun-09 13:29 
GeneralRe: Read from process Pin
Luc Pattyn13-Jun-09 13:37
sitebuilderLuc Pattyn13-Jun-09 13:37 
GeneralRe: Read from process Pin
thomaxz.tc13-Jun-09 13:47
Memberthomaxz.tc13-Jun-09 13:47 
GeneralRe: Read from process Pin
Luc Pattyn13-Jun-09 14:37
sitebuilderLuc Pattyn13-Jun-09 14:37 
GeneralRe: Read from process Pin
thomaxz.tc14-Jun-09 0:32
Memberthomaxz.tc14-Jun-09 0:32 
Questionload a lot of Images to memory Pin
nryk13-Jun-09 9:57
Membernryk13-Jun-09 9:57 
hi i want to load a lot of images to the memory.
of course every bitmap in the memory takes about 10 times more then in the file;
so (if there is no other way) i'm loading the image as a byte array:

private byte[] FileToByteArray (string path)
{
byte[] bytes = null;
using (System.IO.Stream stream = File.OpenRead(path))
{
using (System.IO.BinaryReader reader = new BinaryReader(stream))
{
bytes = reader.ReadBytes((int)reader.BaseStream.Length);
}
}
return bytes;
}

and store it into a byte array variable.
when i need the image i use:

private Image ByteArrayToImage(byte[] byteArrayIn)
{
if (byteArrayIn == null)
return null;
MemoryStream ms = new MemoryStream(byteArrayIn);
Image returnImage = Image.FromStream(ms);
return returnImage;
}

so far so good, the problem is if the image need to be change i send it to a function and get new bitmap, now i want to save it back to byte array, so if i use:

private byte[] ImageToByteArray(System.Drawing.Image imageIn)
{
if (imageIn == null)
return null;
MemoryStream ms = new MemoryStream();
imageIn.Save(ms,System.Drawing.Imaging.ImageFormat.Png);
imageIn.Dispose();
return ms.ToArray();
}

i get a byte array that is about 10 times bigger. so how can i get a smaller byte array?
AnswerRe: load a lot of Images to memory Pin
Luc Pattyn13-Jun-09 10:37
sitebuilderLuc Pattyn13-Jun-09 10:37 
GeneralRe: load a lot of Images to memory Pin
harold aptroot13-Jun-09 12:55
Memberharold aptroot13-Jun-09 12:55 
GeneralRe: load a lot of Images to memory Pin
Luc Pattyn13-Jun-09 15:29
sitebuilderLuc Pattyn13-Jun-09 15:29 
GeneralRe: load a lot of Images to memory Pin
harold aptroot13-Jun-09 15:36
Memberharold aptroot13-Jun-09 15:36 
GeneralRe: load a lot of Images to memory Pin
Luc Pattyn13-Jun-09 16:17
sitebuilderLuc Pattyn13-Jun-09 16:17 
AnswerRe: load a lot of Images to memory Pin
nryk13-Jun-09 19:05
Membernryk13-Jun-09 19:05 
GeneralRe: load a lot of Images to memory Pin
Dave Kreskowiak13-Jun-09 22:46
mveDave Kreskowiak13-Jun-09 22:46 
AnswerRe: load a lot of Images to memory Pin
Guffa13-Jun-09 22:26
MemberGuffa13-Jun-09 22:26 
GeneralRe: load a lot of Images to memory Pin
nryk13-Jun-09 22:40
Membernryk13-Jun-09 22:40 
GeneralRe: load a lot of Images to memory Pin
harold aptroot13-Jun-09 23:38
Memberharold aptroot13-Jun-09 23:38 
GeneralRe: load a lot of Images to memory Pin
Guffa14-Jun-09 0:30
MemberGuffa14-Jun-09 0:30 
GeneralRe: load a lot of Images to memory Pin
nryk14-Jun-09 1:16
Membernryk14-Jun-09 1:16 
GeneralRe: load a lot of Images to memory Pin
Guffa14-Jun-09 22:18
MemberGuffa14-Jun-09 22:18 
QuestionDockPanel Suite Pin
Rafone13-Jun-09 7:24
MemberRafone13-Jun-09 7:24 
AnswerRe: DockPanel Suite Pin
Henry Minute13-Jun-09 7:34
MemberHenry Minute13-Jun-09 7:34 
GeneralRe: DockPanel Suite Pin
Rafone13-Jun-09 8:18
MemberRafone13-Jun-09 8:18 
Questioncannot load data from database to textbox in Visual c# 2008 Pin
Adekolurejo13-Jun-09 6:52
MemberAdekolurejo13-Jun-09 6:52 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.