|
i have some data ranged form 0 to 1,i want show these data in color map.
The function "img" in matlab is what i want.With help of this forum,i have solved the problem how to gradually change one assigned color to the other.Now I feel puzzled about this problem,take an example,
I use "0" to represent RGB (255,0,0) and use "1" to represent RGB(0,0,255);then other data values should represent what?How can i make these data gradually changed from RGB(255,0,0) to RGB(0,0,255)?
In fact,i can assgn "0" to repesent any color such as RGB (0,0,0) and so on,and "1"can represent any colors ,then make one color gradually change to the other.
-- modified at 22:46 Tuesday 25th April, 2006
|
|
|
|
|
It can be simply done as follows, but i don't know whether it will meet your need...
COLORREF rgb1 = RGB( 255, 0, 0 );
COLORREF rgb2 = RGB( 0, 0, 255 );
float fVal = 0.5;
int nR1 = GetRValue( rgb1 );
int nG1 = GetGValue( rgb1 );
int nB1 = GetBValue( rgb1 );
int nR2 = GetRValue( rgb2 );
int nG2 = GetGValue( rgb2 );
int nB2 = GetBValue( rgb2 );
int nR = nR1 + ( nR2 - nR1 ) * fVal;
int nG = nG1 + ( nG2 - nG1 ) * fVal;
int nB = nB1 + ( nB2 - nB1 ) * fVal;
COLORREF rgb = RGB( nR, nG, nB );
- NS -
|
|
|
|
|
When I change large arrays from 'float' to 'double' I got error message.
I need to use 'double' for six large arrays each has size [16200].
Please advise.
Thanks
-- modified at 22:10 Tuesday 25th April, 2006
|
|
|
|
|
I guess you asked the same question yesterday!
As they said dynamically allocate memory.
Nibu thomas
Software Developer
|
|
|
|
|
After changing to double the three large arrays I print out (thr last three column)looks like:
monitor# 1 sampling rate 0.0002441
0.0000 -1.#IO -1.#IO -1.#IO
0.0002 -1.#IO -1.#IO -1.#IO
0.0005 -1.#IO -1.#IO -1.#IO
0.0007 -1.#IO -1.#IO -1.#IO
.........
.........
|
|
|
|
|
mrby123 wrote: When I change large arrays from 'float' to 'double' I got error message.
Mind readers we are not. What is the exact error message?
"Let us be thankful for the fools. But for them the rest of us could not succeed." - Mark Twain
"We will be known forever by the tracks we leave." - Native American Proverb
|
|
|
|
|
Hi, I spawn a process to open 'rsh.exe' (c:\windows\system32\rsh.exe), and I'm trying to change the text that appears on the command prompt window title bar, by using this command from my calling function: 'this->SetWindowText("test")'.
This works in Visual Studio, but oddly, the same code brought over to Visual C++ .NET, does not work due to the 'this' pointer being null! Any suggestions on how to accomplish this?
Thanks
-- modified at 22:03 Tuesday 25th April, 2006
|
|
|
|
|
Have you used SetConsoleTitle ?
Nibu thomas
Software Developer
|
|
|
|
|
How to make a .OLB file in VC++?
Thanks in advance.
|
|
|
|
|
You guys have been a big help with my previous question, I have another.
I have input file "input.txt"
i have outputfile "output.txt"
input.txt will always look like
A 1 5 4
B 2 6 3
the first value can be a different, but will always be one char in length.
I want to grab each value on the first and second line and assign variables to them.
i've looked a lot about inFile.get or .getline or .peek, but it's not making a whole lot of sense.
I have this:
ifstream inf;
ofstream outf1;
ofstream outf2;
inf.open(argv[1], ios::in);
outf1.open(argv[2], ios::in);
outf2.open(argv[2], ios::out);
char n, x, y, z;
while(!inf.eof())
inf.get >> n >> x >> y >> z;
Can anyone shed any light?
Thanks,
Ed
|
|
|
|
|
Reading a char doesn't skip white space and you don't need the get . Try this:
inf >> n >> ws >> x >> ws >> y >> ws >> z >> ws;
The ws manipulator can be used to explicitly skip white space.
Steve
|
|
|
|
|
i tried something like that, but i get this error:
error C2475: 'std::basic_istream<_Elem,_Traits>::get' : forming a pointer-to-member requires explicit use of the address-of operator ('&') and a qualified name
with
[
_Elem=char,
_Traits=std::char_traits<char>
]
error C2475: 'std::basic_istream<_Elem,_Traits>::get' : forming a pointer-to-member requires explicit use of the address-of operator ('&') and a qualified name
with
[
_Elem=char,
_Traits=std::char_traits<char>
]
warning C4552: '>>' : operator has no effect; expected operator with side-effect
|
|
|
|
|
I was wrong about the fact that reading a char doesn't skip white space. I used the following test program and was able to read in data like yours however:
-----
// Console.cpp : Defines the entry point for the console application.
//
#include "stdafx.h"
#include <fstream>
#include <iostream>
using namespace std;
int main(int argc, char* argv[])
{
ifstream in("C:\\a.txt");
char n, a, b, c;
while (in >> n >> a >> b >> c)
{
cout << n << " " << a << " " << b << " " << c << endl;
}
return 0;
}
Steve
|
|
|
|
|
worked like a charm, Steve.
Thank you!
|
|
|
|
|
Steve, one last quick one, if I have two lines, how would I handle that?
my input file reads:
A 1 2 3
B 4 5 6
|
|
|
|
|
It should work with multiple lines. It will work with or without multiple lines. If reads the 1st character into n and the 2d, 3rd and 4th into a, b, c, respectively. Then it repeats the process. What exactly do you want to do with the data?
Steve
|
|
|
|
|
i came up with this...
char n, x, y, z, n2, x2, y2, z2;
while(!inf.eof())
inf >> n >> x >> y >> z >> n2 >> x2 >> y2 >> z2;
but was just seeing if there was a more efficient way of grabbing it.
in the large scheme of things, I am reading in this values:
A 1 5 7
B 2 4 5
which are actually points on a grid. so they are A(1,5,7) and B(2,4,5). Now I use those values and plug them into my class to do calculations. I never really worked with the ifstream much and i thank you again for your assistance!
-Ed
|
|
|
|
|
Can you show the code which plugs the data into your class?
Steve
|
|
|
|
|
im messing with that right now, but I can show you what I have so far...
int main(int argc, char* argv[])
{
ifstream inf;
ofstream outf1;
ofstream outf2;
inf.open("input.txt", ios::in);
outf1.open("output.txt", ios::in);
outf1.close();
outf2.open("output.txt", ios::out);
char n, x, y, z, n2, x2, y2, z2;
while(!inf.eof())
inf >> n >> x >> y >> z >> n2 >> x2 >> y2 >> z2;
Point p0;
Point p1(x,y,n);
Point3D p1(z);
p1.printP();
Point p2(x2,y2,n2);
Point3D p2(z3);
p2.printP();
system("pause");
/* inf.close();
outf2.close();
return 0;*/
}
I am working on a piece that exhibits inheritance. Basically Point class is already defined. I am inheriting it into Point3D class. I am getting my values from the input file, computing the distance between the points, then outputing to an output file.
|
|
|
|
|
I obviously can't pass char into my functions, i need to convert my input variables into integers. I was playing around with the int function, but I think that is giving me the ascii value. How can I make
char "1" = int 1
|
|
|
|
|
There are problems with this code: you have 2 variables called "p1" and 2 called "p2".
Anyway here how I'd read in a list of points:
----
// Console.cpp : Defines the entry point for the console application.
//
#include "stdafx.h"
#include <fstream>
#include <iostream>
#include <vector>
#include <string>
using namespace std;
// Our point structure.
class My3DPoint
{
public:
My3DPoint() : x(0), y(0), z(0) {}
My3DPoint(int _x, int _y, int _z) : x(_x), y(_y), z(_z) {}
int x, y, z;
};
// A collection of "My3DPoint"s.
typedef vector<My3DPoint> My3DPoints;
int main(int argc, char* argv[])
{
ifstream in("C:\\a.txt");
My3DPoints points;
string label;
int x, y, z;
while (in >> label >> x >> y >> z)
{
points.push_back(My3DPoint(x, y, z)); // Add it to our collection.
}
// Now print the collection (in reverse order for fun):
typedef My3DPoints::reverse_iterator RI; // To save some typing.
for ( RI i=points.rbegin(); i!=points.rend(); ++i )
{
const My3DPoint &pt = *i;
cout << "(" << pt.x << ", " << pt.y << ", " << pt.z << ")\n";
}
return 0;
}
Steve
|
|
|
|
|
|
I'm developing a browser using my own version of something simular to MFC's CHtmlView control. I've got all the good stuff in place - a pointer to IWebBrowser2, various event sinks, etc.
What I would like to know is, after (or during) the web browser control navigates to a page -- how can I determine what (if any) the "Favorites Icon" is for that page?
I know that I can look for favicon.ico at the location, or I can manually parse the HTML to look for it specified there, however I have to assume Microsoft has exposed some sort of COM interface that allows me to grab this icon without going through all that drudgery.
Does anyone know how I can do it? I'm not looking for exact instructions, I would just appreciate a pointer (no pun intended) to some sort of interface or any other bit of information to set me in the correct direction.
Thanks!
|
|
|
|
|
Haven't tried it and don't know if it will work but the path I would head down is below. Keep in mind I've never done this and have not worked in C/C++ for a while and when I did it wasn't web related.
I'd call CHttpRequest::GetURL[^] and I would try to get "http://www.websiteofinterest.com/favorite.ico" if true you are good if false handle it and try something else. I have not tested this nor do I know if it will work but it should without any trouble.
MODIFIED: That actually doesn't look like the right function to use. I think that's a server-side call you would make. In theory my idea holds find the right function and you should be good to go.
The enemy's gate is down.
Welcome to CP in your language. Post the unicode version in My CP Blog[^] now.
People who don't understand how awesome Firefox is have never used CPhog. The act of using CPhog alone doesn't make Firefox cool. It opens your eyes to the possibilities and then you start looking for other things like CPhog and your eyes are suddenly open to all sorts of useful things all through Firefox. - (Self Quote)Last modified: Tuesday, April 25, 2006 10:11:18 PM --
|
|
|
|
|
I bow down to the code-frog for responding :bow down:, but unfortunately that's not exactly what I'm looking for.
I already know how to get favicon.ico using WinInet (or whatever).
The thing is that the spanky way to specify a favorite icon for a site is to insert it's reference into the HTML. So looking for favicon.ico doesn't necessarily work. I know how to parse the HTML to find this info, but that's a lot of work - especially since it should already be available via a COM interface at my fingertips.
IE exposes practically everything via COM interfaces... so there has to be something to figure out what the Favorites Icon is for a particular web page (isn't there???)...
Or am I just asking questions without answers?
|
|
|
|
|