|
unsigned char *px = new unsigned char[bm.bmHeight*bm.bmWidthBytes];
bitmap->GetBitmapBits(bm.bmHeight*bm.bmWidthBytes,px);
i found px[2] is a red color BYTE.
whereas px[0] and px[1] is what color BYTE.
Thank you!
Hello World!
|
|
|
|
|
Windows generally stores 24 and 32 bit images as BGR, rather than RGB.
Christian
I have drunk the cool-aid and found it wan and bitter. - Chris Maunder
|
|
|
|
|
unsigned char *px = new unsigned char[bm.bmHeight*bm.bmWidthBytes];
bitmap->GetBitmapBits(bm.bmHeight*bm.bmWidthBytes,px);
if my image is 24 bit, the px array is stored as neither BGR nor RGB.
why so?
Thank you!
Hello World!
|
|
|
|
|
The only possible reaon I can think of is my first hunch - GetBitmapBits does not work. Actually, I think it does, only if your bitmap is a DIBSection.
Christian
I have drunk the cool-aid and found it wan and bitter. - Chris Maunder
|
|
|
|
|
Hello, everyone!
How to get network interface name of local machine? For example, the value of my machine is "NDIS 5.0 driver" and "MS TCP Loopback interface".
Thanks in advance,
Geo
|
|
|
|
|
use the GetAdaptersInfo API!
Don't try it, just do it!
|
|
|
|
|
Hello just respond to this and I'll send an E-mail to you with the source code attachment, yes this is done in visual c++ 6. Tic tac toe thing. Would need suggestions if any and help. would be forever in dept.
<marquee>Universal Project... Soon to be a .net
|
|
|
|
|
you can send this to kotbegemotus[at]rambler.ru
|
|
|
|
|
my e-mail is hisham86@aucegypt.edu
i have the same orblem but i have to solve it with trees
|
|
|
|
|
Does anyone know what kind of number generators are out there and what is your opinion on which is the best one, C++ console, not mfc or visual c++ 6. Thx.
<marquee>Universal Project... Soon to be a .net
|
|
|
|
|
|
It depends on how "random" you need your random numbers to be. The standard (ANSI C) rand() function should be random enough for most general-purpose applications, but on some platforms be aware that the lower-order bits may be much less random than the higher-order bits. AFAIK, most implementations of rand() use the "linear congruential formula":
http://www.taygeta.com/rwalks/node1.html[^]
Another random number generation algorithm is the Mersenne Twister:
http://www-personal.engin.umich.edu/~wagnerr/MersenneTwister.html[^]
Of course, the strongest random number generators are ones which use a random natural source rather than an algorithm. Under Linux, the /dev/random device collects entropy in the form of timings between hardware interrupts. The downside to these generators are the fact that you can quickly exhaust the supply of random bits from the source and thus have to wait while the device collects more data. Other potential natural sources of random bits are measurements of radioactive decay and even lava lamps (as implemented by a team at SGI, using the image data from a webcam pointed at the lamps).
For much more in-depth information about random number generation, see: "Numerical Recipes in C: The Art of Scientific Computing", particularly chapter 7 ("Random Numbers"). The authors go through a number of random number generation algorithms with varying randomness.
- Mike
|
|
|
|
|
Michael Imamura wrote:
Of course, the strongest random number generators are ones which use a random natural source rather than an algorithm.
On Windows, use CryptGenRandom . This uses the process ID, thread ID, milliseconds since boot, current local time, the high-precision performance counters accessed by QueryPerformanceCounter , a hash of the environment block, some of the processor's internal counter registers, and various of the system's running counters (things like bytes transferred per second, context switches per second). Information from Writing Secure Code, Second Edition (Michael Howard & David LeBlanc, MS Press).
|
|
|
|
|
I want to create a slider control by command. I have done following but it doesn't appears in the dialog
<br />
CSliderCtrl m_createslider;<br />
const RECT rc = {20,200,500,60};<br />
m_createslider.Create (WS_TABSTOP|WS_CHILD|WS_VISIBLE|TBS_AUTOTICKS |TBS_TOOLTIPS|TBS_RIGHT|TBS_BOTTOM , <br />
rc, this, IDC_MYSLIDER);<br />
m_createslider.ShowWindow(SW_SHOW);<br />
Please tell me why.
vhunghl
|
|
|
|
|
Where did you put this code?
If you put it in OnInitDialog(), the slider will be destroyed when you exit this function because m_createslider goes out of scope. Declare m_createslider as a member of your dialog class.
|
|
|
|
|
I have declared folowing
<br />
class CexplDlg : public CDialog<br />
{<br />
public:<br />
CexplDlg(CWnd* pParent = NULL);
<br />
enum { IDD = IDD_EXPL_DIALOG };<br />
<br />
protected:<br />
virtual void DoDataExchange(CDataExchange* pDX);
<br />
<br />
protected:<br />
HICON m_hIcon;<br />
<br />
virtual BOOL OnInitDialog();<br />
afx_msg void OnSysCommand(UINT nID, LPARAM lParam);<br />
afx_msg void OnPaint();<br />
afx_msg HCURSOR OnQueryDragIcon();<br />
DECLARE_MESSAGE_MAP()<br />
public:<br />
CSliderCtrl m_createslider; <br />
};<br />
|
|
|
|
|
I have called waveOutReset command and then waveOutClose command, but it doesn't happen MM_WOM_DONE event.
vhunghl
|
|
|
|
|
Hi,
This might sound a bit silly as this is not supposed to be a question in the VC++ forum. Nevertheless, I hope I can get an answer from somebody
How to find whether a file already exists in a folder?
Regards and thanks in advance
Deepak Samuel
|
|
|
|
|
WIN32_FIND_DATA wsd;
HANDLE hFind = FindFirstFile(pszFileName, &wsd);
if(hFind != NULL)
{
//the file does exist
}else{
MessageBox(NULL, "Error", "The specified file does not exist.",MB_OK);
}
FindClose(hFind);
|
|
|
|
|
Open up "My Computer" and double-click the folders to the right directory...
I take it you're asking about file existance from an fstream point of view. If you're looking if "foo.txt" exists you can do something like the following:
ifstream fin( "foo.txt" );
if ( fin )
{
}
else
{
}
You could also use the ios flags ios::nocreate and ios::noreplace with an ofstream object:
ofstream fout( "foo.txt" ios::noreplace )
if ( fout )
{
}
else
{
}
||
ofstream fout( "foo.txt" ios::nocreate )
if ( fout )
{
}
else
{
}
Hopefully that helped a little.
Always Fear the Man with Nothing to Lose
Jeryth
|
|
|
|
|
From MSDN Library
/* ACCESS.C: This example uses _access to check the
* file named "ACCESS.C" to see if it exists and if
* writing is allowed.
*/
#include <io.h>
#include <stdio.h>
#include <stdlib.h>
void main( void )
{
/* Check for existence */
if( (_access( "ACCESS.C", 0 )) != -1 )
{
printf( "File ACCESS.C exists\n" );
/* Check for write permission */
if( (_access( "ACCESS.C", 2 )) != -1 )
printf( "File ACCESS.C has write permission\n" );
}
}
http://msdn.microsoft.com/library/default.asp?url=/library/en-us/vccore98/html/_crt__access.2c_._waccess.asp
|
|
|
|
|
I'm new to operator overloading so this may come off as a stupid question, but I'll risk it. I'm making a simple BlackJack game and have two ENUM s that I want operators to work on. Here's a little of what I'm working with:
enum SUIT { CLUB, DIAMOND, SPADE, HEART };
void operator++( SUIT &suit )
{
switch( suit )
{
case( CLUB ):
suit = DIAMOND;
break;
case( DIAMOND ):
suit = SPADE;
break;
case( SPADE ):
suit = HEART;
break;
case( HEART ):
suit = CLUB;
break;
default:
;
}
}
The '--' operator looks nearly identical. I keep getting a compile error C2676: binary '++' : 'SUIT' does not define this operator or a conversion to a type acceptable to the predefined operator. Where's my problem coming from? Also, any ideas for tricks to overload the '+' & '-' operators without having to make a very long switch ?
Always Fear the Man with Nothing to Lose
Jeryth
|
|
|
|
|
Your code seems to work fine in VS.NET 2K3:
SUIT f = CLUB;
++f; Are you trying to use the postfix version of operator++ ? If so, you need to add another function with a dummy int parameter:
SUIT operator++(SUIT &suit,int){
SUIT old = suit;
++suit;
switch( old ) {
case( CLUB ):
return DIAMOND;
break;
case( DIAMOND ):
return SPADE;
break;
case( SPADE ):
return HEART;
break;
case( HEART ):
return CLUB;
break;
default:
return DIAMOND;
}
}
- Mike
|
|
|
|
|
No it was prefix and I'm on 2K3 as well. However your code had a return on it. I understand the purpose of the return here, postfix == fetch value THEN increment, does the prefix need one too?
Always Fear the Man with Nothing to Lose
http://www.dragonfiresoft.com
Jeryth
|
|
|
|
|
You can choose to have a return or not on the prefix, but to maintain the standard semantics of prefix increment it really should return a value. So, the declaration for the function changes to:
const SUIT &operator++(SUIT &suit) and just add
return suit; to the end of the function.
For reference, here's the test program I'm using:
enum SUIT { CLUB, DIAMOND, SPADE, HEART };
const SUIT &operator++(SUIT &suit) {
switch( suit ) {
case( CLUB ):
suit = DIAMOND;
break;
case( DIAMOND ):
suit = SPADE;
break;
case( SPADE ):
suit = HEART;
break;
case( HEART ):
suit = CLUB;
break;
default:
;
}
return suit;
}
SUIT operator++(SUIT &suit,int){
SUIT old = suit;
++suit;
return old;
}
int _tmain(int argc, _TCHAR* argv[]) {
SUIT f = CLUB;
SUIT v = ++f;
return 0;
} Note the fixed postfix increment... I blame insufficient caffeine when I replied earlier
- Mike
|
|
|
|