hi..
i'm trying to load a file with .pgm extension on picture box ... i really need help .. so .. any help here??!! :(

Is this "picture box" a visual studio thing?

hi..
now i'm trying to use openfiledialog to read from file ..
first i decalre a cli::array<unsigned char> ^buffer
then sent it as a parameter to openfile()->read function
then i used ToString function ..to convert buffer to string
then i tried to show what i got in a msg box .. but the msg that come up is : system byte[]


i know .. i have much mistakes overhere .. and some missuse of functions ..
all what i want ..

1. to open file
2. read some thing from file
3. skip a line in the file
3.to convert the contents of the file into 2D array

What does the file contain? (text or binary)
If it's text, look up StreamReader and read it directly into a string in one fell swoop with the ReadToEnd() method.

If you use ToString() on an object that does not have an override for that method you get the class name back.

Is this what your other thread is about too? I posted on that one. Try to keep it in the one thread if it's all the same issue. That way nobody gets confused.

Update: This is doable with reading in the PGM as text, line by line.
It is possible to convert the pgm into a bitmap (there is an existing library http://netpbm.sourceforge.net/doc/libnetpbm.html but dealing with the managed/unmanaged interface might be tedious).

If all you need is a way to display the image then make an array of pictureboxes each one as a "pixel" and change the background of the PB to the appropriate grayscale value.

Threads merged. Please do not flood forum

i'm sorry for doing much threads.. i thought that they were differnt issues ..

great.. i read the link above then i tried to work ..but the visual studio tell me that the libaray is not exist .. so i need the library it self so i can use the functions in the link.. can i get any idea to how to get such library??

now i need help.. how to use it in my program in visual studio :(

Even if you have the library set up properly it's going to be a chore to exchange all the unmanaged and managed data. See http://gregs-blog.com/category/ccli/ for a good example of using the marshal technique. Especially with moving large arrays back and forth as you would for the images it could get tedious.

Did you successfully read in the .pgm file into an array?(from you other post) I would make sure you've got that down first and worry about displaying it in the picturebox later on. See http://en.wikipedia.org/wiki/BMP_file_format for a description of the bitmap format, as you can probably build a bitmap out of the grayscale data that you get from the PGM. Consider that other option that I gave you also where you make a picturebox out of a bunch of little contiguous pictureboxes each one representing a pixel.

great .. that a brilliant idea ..
but now there's another query .. i'm sorry ..i know that i had much queries ..

i'm trying to use stl library in a windows application project in visual studio .. i used to use it in console application prjects with ... # include <vector> as example
but when i tried to do so in windows application the visual studio show me an error

so how can i use stl in a window application project

great .. that a brilliant idea ..
but now there's another query .. i'm sorry ..i know that i had much queries ..

i'm trying to use stl library in a windows application project in visual studio .. i used to use it in console application prjects with ... # include <vector> as example
but when i tried to do so in windows application the visual studio show me an error

so how can i use stl in a window application project

Use a .NET container instead. You can use a System::Collections::ArrayList (wbich stores things as type "object" -- they must be casted back to their original type to be used) or a System::Collection::Generic::List . I was looking for an article that explains the difference between managed and unmanaged code for you but the ones I found were a bit outdated. See http://en.wikipedia.org/wiki/C%2B%2B/CLI for an "ok" overview.

that's good .. but now , i searched for : is list<T> act as array in memory
and linkedlist<T> acts as linked list in memory .. it's the core of my report

great
another point overhere .. :)

i'm trying to write to file ok
then i used a streamwrtier then try to write to file some characters .. and they were written successfully
but when i tried to read them as byte i faced a character byte with value 13 .. i didn't write it
as eg. i white in my code

strmwrtr->writeline("P2");

i found
80 = P then
50 = 2 then
13 -----> my problem
i searched the net how can i avoid this .. but .. nothing

Hello there,
for working with images I like to use the OpenCV library, it's very simple
and powerful.

Cheers!

great
another point overhere .. :)

i'm trying to write to file ok
then i used a streamwrtier then try to write to file some characters .. and they were written successfully
but when i tried to read them as byte i faced a character byte with value 13 .. i didn't write it
as eg. i white in my code

strmwrtr->writeline("P2");

i found
80 = P then
50 = 2 then
13 -----> my problem
i searched the net how can i avoid this .. but .. nothing

WriteLine() puts a "\r\n" after your text. Use Write() instead.

Hello there,
for working with images I like to use the OpenCV library, it's very simple
and powerful.

Cheers!

For .NET you would need a wrapper like http://www.emgu.com/wiki/index.php/Main_Page (there are a few others but that one is recently maintained).

i got it :)
just don't use writeline
write 10 by ur self :)

@rcorcs : great ... i'll try it :)

now i'm trying to use System::collection::Generic::array
and List and LinkedList
i tried to set the array type of my defined type
as i made a new class
then included this class in my project
but when i write
array< myclassname> anyname ;

the compiler tells me this error:
Generic type argument for'T' can not be 'myclassname' , it must be a value type or a handle to a reference type

so what can do
noting that my project is a windows application project not console one so i can't use STL

If it's a ref class you need array<myclassname^> (^ is a pointer to a garbage collected value). There are some great tutorials over at http://www.functionx.com/cppcli/index.htm (their winforms stuff is kinda mediocre but the language stuff is pretty thorough).

thanks.. i'll try that now

how can i get the time elapsed in execution certain part of code

For .NET you can use a System::Diagnostics::Stopwatch It has Start() and Stop() methods. Use the property ElapsedMilliseconds to get the amount of time. See http://msdn.microsoft.com/en-us/library/system.diagnostics.stopwatch.aspx.

There are other ways to do it but they are not all compatible with the managed code (there are some Win32 API calls that you can P/Invoke for example).

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.