473,396 Members | 1,789 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,396 software developers and data experts.

Images from memory

i am using a dll that places an image data in memory and returns to me two wariable long P1 and long P2
i am using C#
P1 is the memory address and P2 is the number of bytes written
i want to place this image in a picturebox named pictureBox1 how can i do this

in c++ the code works like this
stream.write((void*) P1,P2);
its equavalent in C# should be
Stream str = new MemoryStream()
str.Write((void*) P1,0,P2);
pictureBox1.Image = Image.FromStream(str);

or
Stream str = new MemoryStream((void*) P1,0,P2)
pictureBox1.Image = Image.FromStream(str);

my problem P1 is pointer and str.Write function takes a byte array . how can i take the data at P1 and convert it to byte array or from an image from it.

---
Posted using Wimdows.net NntpNews Component -

Post Made from http://www.DotNetJunkies.com/newsgroups Our newsgroup engine supports Post Alerts, Ratings, and Searching.
Nov 16 '05 #1
1 1189
Try this

//include namespace
using System.Runtime.InteropServices ;
using System.Text;
string str = Marshal.PtrToStringAuto(P1);
UnicodeEncoding encod = new UnicodeEncoding();
byte [] imageBytes = encod.GetBytes(str);

Stream myStream = new MemoryStream(imageBytes);
Image myImage = Image.FromStream(stream);

pictureBox1.Image = myImage;

--
Shak
(Houston)


"DotNetJunkies User" <User@-NOSPAM-DotNetJunkies.com> wrote in message
news:#z*************@TK2MSFTNGP12.phx.gbl...
i am using a dll that places an image data in memory and returns to me two wariable long P1 and long P2 i am using C#
P1 is the memory address and P2 is the number of bytes written
i want to place this image in a picturebox named pictureBox1 how can i do this
in c++ the code works like this
stream.write((void*) P1,P2);
its equavalent in C# should be
Stream str = new MemoryStream()
str.Write((void*) P1,0,P2);
pictureBox1.Image = Image.FromStream(str);

or
Stream str = new MemoryStream((void*) P1,0,P2)
pictureBox1.Image = Image.FromStream(str);

my problem P1 is pointer and str.Write function takes a byte array . how can i take the data at P1 and convert it to byte array or from an image from
it.
---
Posted using Wimdows.net NntpNews Component -

Post Made from http://www.DotNetJunkies.com/newsgroups Our newsgroup

engine supports Post Alerts, Ratings, and Searching.
Nov 16 '05 #2

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

Similar topics

2
by: Dave Griffiths | last post by:
Hi all Very new to JavaScript, I am trying to cache a number of images as the page loads, is there a max number of images or memory usage before the browser stops caching. My PC has 1G ram so...
22
by: Fabian | last post by:
var preload1 = new Image(); preload1.src = "/pic/yay.gif"; var preload2 = new Image(); preload2.src = "/pic/nay.gif"; The above is meant to preload image files, yes? Problem is, it doesnt seem...
3
by: mraj | last post by:
Hello... I am new to C#. My requirement is that, I will receive over 100s of images from the network to local machine and display these images on an image viewer one by one on mouse scroll. To...
61
by: phil-news-nospam | last post by:
Why does SVG need a different tag than other images? IMHO, SVG should be implemented as an image type just like any other image type, allowing it to work with <img> tags, and ... here is the...
12
by: comp.lang.php | last post by:
index.php: // STUFF // STEP 1: imagecreatetruecolor ONLY IF GD 2.0+ SUPPORTED AND FOUND if ($this->isSuccessful && !$hasMogrified && $image && !$newImage &&...
2
tpgames
by: tpgames | last post by:
Me memory game freezes after I click some cards. I seems to be random as to the number of clicks needed before it freezes. I posted the entire code, as I am not sure what is needed for help. I am...
18
tpgames
by: tpgames | last post by:
How do I get code to access the images at the URL given? I'd like the user to be able to select which theme of images they want to view then the script would randomly pick an image to show. ...
3
by: pedrito | last post by:
I've got an app that downloads images off the internet using anywhere from 1-20 threads concurrently (though generally around 4 threads). I have a preview page that shows the images as they're...
7
by: Keith Hughitt | last post by:
Hi all, I am having trouble preloading images in a javascript application, and was wondering if anyone had any suggestions. Basically I have a bunch of images stored in a database as BLOBs. At...
5
matheussousuke
by: matheussousuke | last post by:
Hello, I'm using tiny MCE plugin on my oscommerce and it is inserting my website URL when I use insert image function in the emails. The goal is: Make it send the email with the URL...
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: 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
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: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
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...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...

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.