|
See here[^].
Of one Essence is the human race
thus has Creation put the base
One Limb impacted is sufficient
For all Others to feel the Mace
(Saadi )
|
|
|
|
|
In 8 bits bitmap, i learn that it has a color table in the file and the region
of bitmap data are indexes of the array. I want to get a part of image from the
orignal 8 bits bitmap, but i don't know the relation between bitmap data and
color table.
If someone know it, please tell me.
you may send it to my email.my email is: shuhua_song@sina.com
Thank you very much!
|
|
|
|
|
songhunhun wrote: but i don't know the relation between bitmap data and
color table.
Since the bitmap is 8 pixel the maximum color it can represent is 256. so the color map will be holding a list of 256 RGB values.
If we want to display the 0th pixel of a bitmap, will take the value present in the data for 0th pixel( the value will be 0 to 255 ), for instances say 75. This means in the 0th pixel, show the color in 75th index of color table.
|
|
|
|
|
|
Hi, I've been working on a Point class for about 2 weeks now, and I haven't been able to get anywhere.
The specifications are:
+There are two double data members, x and y
+Write overloaded and default constructors
+Write mutator and accessor functions.
+Write an addition function that returns a Point object. Addition is defined such that the x member of the calling Point and the x member of the rhs (right hand side, i.e., the parameter ) Point are added. Return a new point with the added values.
+Write a subtraction formula that returns a Point object. Subtraction is defined such that the x member of the rhs or parameter is subtracted from the x member of the calling Point. So too for the y member. Return a new point with the subtracted values.
+Write a print function that prints a point as follows: ( 2, 3 )
the main is supposed to be something like this:
main( )
{
Point A(1, 2), B(3, 4), C;
cout << "the x value of A is ";
cout << A.GetX( );
cout << endl << "the y value of A is ";
cout << A.GetY( );
cout << endl << "B is";
B.PrintPoint( );
C = A.AddPoint( B );
cout << endl << "A + B is " ;
C.PrintPoint( ) :
C = A.SubPoint( B );
cout << endl << "A - B is " ;
C.PrintPoint( ) :
cout <<endl << "Set C to (0, 4):";
C.SetX(0);
C.SetY(4);
cout << endl << "C is now " ;
C.PrintPoint( );
return 0;
}
anything helps!
thanks!
|
|
|
|
|
You have a potential bug in your specification (yes, really)
Addition does not affect Y. Shouldn't it? Usually it should.
But what are you having trouble with, exactly? I don't see any big problems here..
|
|
|
|
|
That is fairly basic stuff. What have you done, so far?
If the Lord God Almighty had consulted me before embarking upon the Creation, I would have recommended something simpler.
-- Alfonso the Wise, 13th Century King of Castile.
This is going on my arrogant assumptions. You may have a superb reason why I'm completely wrong.
-- Iain Clarke
[My articles]
|
|
|
|
|
Can I suggest you look at this tutorial[^]? It uses a Rectangle class as a sample, which is close enough to a Point that you should be able to work out what's waht?
Java, Basic, who cares - it's all a bunch of tree-hugging hippy cr*p
|
|
|
|
|
any body help me in implementation of berlekamp massey algorithm
|
|
|
|
|
|
hi
i find the linear complexty of sequence but how i find the polyomial
|
|
|
|
|
|
hi
this is not a simple berlekamp massey algorithm
i need the simplest algorith to find the linear complexity
the code is available here at codeproject but it is not runnable i do not understand
|
|
|
|
|
Hi,
does anyone know some simple example how to play or capture audio from
internet stream?
Is there any SDK or DirectSound function(s) to implement such think.
Thank you
viliam
|
|
|
|
|
I want to run my exe in admin always irresepective of the user. ofcourse i dont want to run from the run as option. can any one tell me how i will programatically do that.?
birajendu
CyberG India
Delhi
India
|
|
|
|
|
|
Use AdjustTokenPrivileges() . Some examples are here, and in this article about 1/3 of the way down.
"Old age is like a bank account. You withdraw later in life what you have deposited along the way." - Unknown
"Fireproof doesn't mean the fire will never come. It means when the fire comes that you will be able to withstand it." - Michael Simmons
|
|
|
|
|
I have written a multithreaded application, and am wondering if I need to declare any of the shared variables as volatile. I have searched online for a while, but have thus far found no definitive source on when you need to use this qualifier. My code operates similarly to the following:
#include <windows.h>
#define ITER_COUNT 300
#define BUFF_SIZE 10
class Buffer {
public:
const size_t length;
const HANDLE canWrite;
const HANDLE canRead ;
double* data ;
size_t writeIdx;
size_t readIdx ;
Buffer(size_t maxSize) :
data(new double[maxSize]()),
writeIdx(0), readIdx(0), length(maxSize),
canWrite(CreateSemaphore(NULL, static_cast<LONG>(maxSize),
static_cast<LONG>(maxSize), NULL)),
canRead (CreateSemaphore(NULL, 0 ,
static_cast<LONG>(maxSize), NULL)) { }
virtual ~Buffer() {
delete[] data;
CloseHandle(canWrite);
CloseHandle(canRead );
}
};
void ThreadFunc(void* var) {
Buffer& buffer(*static_cast<Buffer*>(var));
for (size_t idx = 0; idx < ITER_COUNT; ++idx) {
WaitForSingleObject(buffer.canWrite, INFINITE);
for (size_t j = 0; j < 5; ++j) {
buffer.data[buffer.writeIdx] += idx + j;
}
ReleaseSemaphore (buffer.canRead, 1, NULL);
buffer.writeIdx = (buffer.writeIdx + 1) % buffer.length;
}
}
void main() {
double result = 0;
Buffer buffer(BUFF_SIZE);
HANDLE threadHandle = (HANDLE)_beginthread(&ThreadFunc, 0, buffer);
for (size_t idx = 0; idx < ITER_COUNT; ++idx) {
WaitForSingleObject(buffer.canRead, INFINITE);
result += buffer.data[buffer.readIdx];
buffer.data[buffer.readIdx] = 0;
ReleaseSemaphore (buffer.canWrite, 1, NULL);
buffer.readIdx = (buffer.readIdx + 1) % buffer.length;
}
} Clearly the const members need not be volatile, and the read/write indices are only read or modified in a single thread, so those are ok. However, do I need to declare the Buffer::data pointer as volatile or not?
I have another multithreaded application that has n > 1 threads, such that each thread modifies some data prior to exiting, but does so within a mutex-protected bit of code. Should this variable be declared as volatile as well? Thank you in advance for any assistance.
Sounds like somebody's got a case of the Mondays
-Jeff
modified on Thursday, May 7, 2009 3:41 PM
|
|
|
|
|
volatile means that the variable can be modified at any time without the compiler knowing, which means the compiler must always access the variable and not store it in a register.
I think you'll find that volatile is of limited use in a multi-threaded context - explicit serialisation/control of access to shared data is what is needed - critical sections, mutexes etc...
Don't try to design lock-free structures - they're very, very, very difficult to get right. Use locks and minimise the amount of shared data.
Java, Basic, who cares - it's all a bunch of tree-hugging hippy cr*p
|
|
|
|
|
There is no special asm emitted for volatile variables (in x86/x64). It is used by the compiler to restrict optimizations and control instruction ordering only. As Stuart mentioned, it isn't a lot of use (by itself) in mt programming.
Normally you'd want a lock, but a quick scan of your code seems to indicate that the algorithm ensures that main() and ThreadFunc() will always be reading/writing different buffer.data[] indicies - you'd want to make sure this is true, in some sort of formal proof, before letting the code go live.
So, in your case, after ThreadFunc() writes to buffer.data[i] and releases main() to read it, the cpu cache coherency mechanism (x86/x64) will make sure that main() sees the new version of buffer.data[i] if it is running on a different core. You don't need to do anything to make this happen.
See: http://web.ics.purdue.edu/~jvaught/education/EE563_work/lecture/x86_memory_slides.pdf[^]
...cmk
The idea that I can be presented with a problem, set out to logically solve it with the tools at hand, and wind up with a program that could not be legally used because someone else followed the same logical steps some years ago and filed for a patent on it is horrifying.
- John Carmack
|
|
|
|
|
Folks, I have been told that there is one logical problem with this code. Basically, this is an implementation of the library function strcat().
The intended beahviour of this function to concatenate ct to the end of s. Return s.
I could not find any logical problems with the code, apart from the fact that the final string should be NULL terminated, but I am not sure that can be classified as an error.
Could you help me find the error, if there is any.
char *strcat(char *s, const char *ct)
{
int i, start;
start = strlen(s);
for (i = 0; i < strlen(ct); i++)
{
s[start + i] = ct[i];
}
return s;
}
P.S. -
Is this the only correction needed in the code:
s[start+i]='\0'; \\after the loop
|
|
|
|
|
kaku_lala wrote: P.S. -
Is this the only correction needed in the code:
s[start+i]='\0'; \\after the loop
This should happen as part of the normal "copy" loop. For example:
...
while (*s++ = *ct++)
;
return s;
"Old age is like a bank account. You withdraw later in life what you have deposited along the way." - Unknown
"Fireproof doesn't mean the fire will never come. It means when the fire comes that you will be able to withstand it." - Michael Simmons
|
|
|
|
|
If execute, 'Ho' comes out
It is normally though come out '0000' like this
I am carried cost 'Ho'
IDC_LAT cost is carried how
web
modified on Thursday, May 7, 2009 1:56 PM
|
|
|
|
|
yunpil wrote: I come out 'ho' A if execute
It is normally though caption comes out '0000' like this without should come out
I am carried ho cost
IDC_LAT cost is carried how
Was that english ? Seriously, I didn't understand anything about your question. I even don't understand what you are talking about...
|
|
|
|
|
Why do you expect that much from Google Translate
There is sufficient light for those who desire to see, and there is sufficient darkness for those of a contrary disposition.
Blaise Pascal
|
|
|
|