473,385 Members | 1,898 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,385 software developers and data experts.

Save image to file from memory

I am using a network camera that saves the image in a byte array in memory
(via their ocx component, and in the OnNewImage event I can get the pointer
to the image and the byte length as
e.lFrmBytes

e.lPtrToImage

How do I get at that array in memory and save it to disk? It seems to
suggest a pointer which is not supported in VB.

-Jerry

Jun 27 '08 #1
6 4001
Jerry,

For sure you can use in VB Image.Save, there are no Net classes wich are not
supported in VB for Net

Cor


"Jerry Spence1" <je**********@somewhere.co.ukschreef in bericht
news:NP6dnYOgTbuOmL7VnZ2dnUVZ8q6onZ2d@plusnet...
>I am using a network camera that saves the image in a byte array in memory
(via their ocx component, and in the OnNewImage event I can get the pointer
to the image and the byte length as
e.lFrmBytes

e.lPtrToImage

How do I get at that array in memory and save it to disk? It seems to
suggest a pointer which is not supported in VB.

-Jerry
Jun 27 '08 #2
On May 8, 4:50 pm, "Jerry Spence1" <jerry.spe...@somewhere.co.uk>
wrote:
I am using a network camera that saves the image in a byte array in memory
(via their ocx component, and in the OnNewImage event I can get the pointer
to the image and the byte length as
e.lFrmBytes

e.lPtrToImage

How do I get at that array in memory and save it to disk? It seems to
suggest a pointer which is not supported in VB.

-Jerry
Hi Jerry,
If you're able to copy image to clipboard (memory), you can simply
retrieve it into a picturebox and save by using save method. First
make sure image is copied to clipboard.

' To get image from clipboard
PictureBox1.Image = Clipboard.GetImage

' Then save image with a proper path
PictureBox1.Image.Save("image_path.jpg")

Hope this helps,

Onur
Jun 27 '08 #3
Thanks. My problem is how to get at the memory in the first place. Given the
pointer, how do I read it?

-Jerry
"kimiraikkonen" <ki*************@gmail.comwrote in message
news:96**********************************@m73g2000 hsh.googlegroups.com...
On May 8, 4:50 pm, "Jerry Spence1" <jerry.spe...@somewhere.co.uk>
wrote:
>I am using a network camera that saves the image in a byte array in
memory
(via their ocx component, and in the OnNewImage event I can get the
pointer
to the image and the byte length as
e.lFrmBytes

e.lPtrToImage

How do I get at that array in memory and save it to disk? It seems to
suggest a pointer which is not supported in VB.

-Jerry

Hi Jerry,
If you're able to copy image to clipboard (memory), you can simply
retrieve it into a picturebox and save by using save method. First
make sure image is copied to clipboard.

' To get image from clipboard
PictureBox1.Image = Clipboard.GetImage

' Then save image with a proper path
PictureBox1.Image.Save("image_path.jpg")

Hope this helps,

Onur

Jun 27 '08 #4
I think you'll need to use Windows API calls.

Maybe RtlMoveMemory?

I wouldn't be surprised if VB.NET tries to frustrate you, though. VB.NET
programmers aren't really meant to access memory directly.

--
David Streeter
Synchrotech Software
Sydney Australia
"Jerry Spence1" wrote:
Thanks. My problem is how to get at the memory in the first place. Given the
pointer, how do I read it?

-Jerry
"kimiraikkonen" <ki*************@gmail.comwrote in message
news:96**********************************@m73g2000 hsh.googlegroups.com...
On May 8, 4:50 pm, "Jerry Spence1" <jerry.spe...@somewhere.co.uk>
wrote:
I am using a network camera that saves the image in a byte array in
memory
(via their ocx component, and in the OnNewImage event I can get the
pointer
to the image and the byte length as
e.lFrmBytes

e.lPtrToImage

How do I get at that array in memory and save it to disk? It seems to
suggest a pointer which is not supported in VB.

-Jerry
Hi Jerry,
If you're able to copy image to clipboard (memory), you can simply
retrieve it into a picturebox and save by using save method. First
make sure image is copied to clipboard.

' To get image from clipboard
PictureBox1.Image = Clipboard.GetImage

' Then save image with a proper path
PictureBox1.Image.Save("image_path.jpg")

Hope this helps,

Onur


Jun 27 '08 #5
The namespace Microsoft.Win32.SafeHandles Namespace might also yield a clue.
I don't know anything about this namespace, but it looks promising.
--
David Streeter
Synchrotech Software
Sydney Australia
"SurturZ" wrote:
I think you'll need to use Windows API calls.

Maybe RtlMoveMemory?

I wouldn't be surprised if VB.NET tries to frustrate you, though. VB.NET
programmers aren't really meant to access memory directly.

--
David Streeter
Synchrotech Software
Sydney Australia
"Jerry Spence1" wrote:
Thanks. My problem is how to get at the memory in the first place. Given the
pointer, how do I read it?

-Jerry
"kimiraikkonen" <ki*************@gmail.comwrote in message
news:96**********************************@m73g2000 hsh.googlegroups.com...
On May 8, 4:50 pm, "Jerry Spence1" <jerry.spe...@somewhere.co.uk>
wrote:
>I am using a network camera that saves the image in a byte array in
>memory
>(via their ocx component, and in the OnNewImage event I can get the
>pointer
>to the image and the byte length as
>e.lFrmBytes
>>
>e.lPtrToImage
>>
>How do I get at that array in memory and save it to disk? It seems to
>suggest a pointer which is not supported in VB.
>>
>-Jerry
>
Hi Jerry,
If you're able to copy image to clipboard (memory), you can simply
retrieve it into a picturebox and save by using save method. First
make sure image is copied to clipboard.
>
' To get image from clipboard
PictureBox1.Image = Clipboard.GetImage
>
' Then save image with a proper path
PictureBox1.Image.Save("image_path.jpg")
>
Hope this helps,
>
Onur
Jun 27 '08 #6
Try the System.Runtime.InteropServices.Marshal namespace.

--
Joel Lucsy
"The dinosaurs became extinct because they didn't have a space program."
-- Larry Niven
Jun 27 '08 #7

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

0
by: F. Hall | last post by:
If I read a bitmap image from one file and save it to another the save operation is slow unless I draw on the image. In other words, Image inputImage = Image.FromFile( @"c:\temp\source.bmp" );...
5
by: George | last post by:
This program need to draw the some triangles into a 512 × 512 buffer (in memory). Or save it to a file. #include "project3.h" Image::Image(int xres, int yres): xres(xres), yres(yres) {...
0
by: prakash | last post by:
Dear Friends I am new guy to Visual C++.NET I've program to save website as a image vc++.net . It have a function "SaveSnapshot" to save the webpage as an image On that function ifor saving...
2
by: Corobori | last post by:
I am getting an error message "Description: Value cannot be null. Parameter name: encoder" when performing this instruction: frmPicView.pic.Image.Save(ms, frmPicView.pic.Image.RawFormat) Here is...
1
by: Hardy Wang | last post by:
Hi, I found a piece of code to add drop shadow to a photo like below, after I save the image, it is actually a BMP file even though I specify a JPG file extension (see...
15
by: Sharon | last post by:
Hello gurus, I have a System.IntPtr pointing to the memory address of my image (not a ..NET image). I wish to save this image data pointed by the IntPtr to a raw data file. The way I now to...
1
by: liuliuliu | last post by:
hi -- sorry if this is trivial -- but how do you make a screenshot of a pygame display? i have a surface which is basically the entire visible screen -- how do you write this surface as an image...
0
by: crazyyellowguy | last post by:
hi, This is my first post in this forum and I just wanted to thank you for even taking a look at my post. The class that I am writing the C code for is my first computer class and my knowledge is...
2
by: Piotrekk | last post by:
Hi I have a problem. I open bitmap file, load it to memory decrease color palette by proceeding Euclidean distance. As a result i have image reduced to - for example 18 colors. Once i save it -...
0
by: Faith0G | last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...
0
by: ryjfgjl | last post by:
In our work, we often need to import Excel data into databases (such as MySQL, SQL Server, Oracle) for data analysis and processing. Usually, we use database tools like Navicat or the Excel import...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.