|
I am currently using this algorithm to convert a small image on a button from colour to grayscale:
COLORREF background = ::GetSysColor(COLOR_3DFACE);
for(int x = 0; x < width; x++)
for(int y = 0; y < height; y++)
{
COLORREF clr = DC.GetPixel(x, y);
if (clr != background)
{
int grayscale = (((GetBValue(clr) * 11) + (GetGValue(clr) * 59) + (GetRValue(clr) * 30)) / 100);
DC.SetPixelV(x, y, RGB(grayscale, grayscale, grayscale));
}
}
Does anyone know of a better algorithm
---
It may be that your sole purpose in life is simply to serve as a warning to others.
|
|
|
|
|
The scales of red/green/blue look right, but you'd do better to use a DIBSectio, and avoid the speed issue of Get/SetPixel, as well as not needing to select it into a DC.
Christian
After all, there's nothing wrong with an elite as long as I'm allowed to be part of it!! - Mike Burston Oct 23, 2001
Sonork ID 100.10002:MeanManOzI live in Bob's HungOut now
|
|
|
|
|
Does anyone know of a better algorithm
You might want to have a look at the Color space FAQ.
A Google search for "color space RGB" (and other suitable restriction words) should display more than enough. It's a large area...
|
|
|
|
|
Hi everyone. Does anyone know if it is possible to open a read-only Jet (Access) database in code. I know MS Access will allow you to open a read only database, and just warn you when you open it that it is read only and you can't change the database. I recently tried to open a read-only DB in code, and all I did was attempt to open it, open a table and read out some records. It seems to fail when it tried to open the table (and the program then crashes). I tried debugging it, but my code seems ok, and I don't attempt to write anything. Does anyone know for sure?
|
|
|
|
|
I think you should post the relevent code snippets here for anyone to be able to help you.
Nish
Sonork ID 100.9786 voidmain
www.busterboy.org
If you don't find me on CP, I'll be at Bob's HungOut
|
|
|
|
|
I recently tried to open a read-only DB in code
Using what? ODBC? DAO? ADO? OLE-DB? RDO? [insert any new "technology" buzzword that has emerged since that I don't know about].
Without knowing this, we could as well answer "Yes, you can put a man on the moon".
|
|
|
|
|
If you're using DAO, open the database both Exclusive and Read-only. This method does not create an .ldb file.
Joel Lucsy (jjlucsy@ameritech.net)
|
|
|
|
|
Hi !
Does someone know how to create a DialogBar (Dialog window with Toolbar behavior, like MFCs CDialogBar) with WTL or Win API (without using MFC)?
I tried to put a dialog window into a ReBar control, but up to now i wasn`t able to insert a second (vertical) rebar control in my MDI MainFrame correctly without interfearing with the first ReBar ...
Any help is welcome ...
|
|
|
|
|
Is there side-effects to using two (different) #pragma pack () statements in a single header file?
I have the following:
#pragma pack (push, firstPragma)
#pragma pack (2)
...
typedef struct
{
blah,...
} STRUCT_A;
...
#pragma pack (pop, firstPragma)
#pragma pack (push, secondPragma)
#pragma pack (4)
...
typedef struct
{
blah,...
} STRUCT_B;
#pragma pack (pop, secondPragma)
Im very curious on this issue.
Thanks.
|
|
|
|
|
You can simply that with
#pragma pack(push, firstPragma, 2)
struct
#pragma pack(pop, firstPragma)
#pragma pack(push, secondPragma, 4)
struct
#pragma pack(pop, secondPragma)
Todd Smith
|
|
|
|
|
hi,
i made a modal dialog, and i called him
in
void CBankView::OnFileConnect()
{
// TODO: Add your command handler code here
ConectDialog dlg;
dlg.m_strHost="127.0.0.1";
dlg.m_uintPort=6699;
dlg.m_strServerName="MYSQLSERVER";
dlg.m_strUser="username";
int ret=dlg.DoModal(this);
...
then when the user click on OK, i predefined
the onOK function and then i want to call my CBankView->Connect()
function, but i don't know how to get pointer to my
CBankView ot my CBankDoc objects
pls help me.
|
|
|
|
|
Stanislav wrote:
int ret=dlg.DoModal(this);
How did you compile that?
CDialog's DoModal is defined as :-
virtual int DoModal();
But you can do this :-
GetParent()->GetActiveView()->YourFunction() from your modal dialog.
Casting might be required.
Nish
Sonork ID 100.9786 voidmain
www.busterboy.org
If you don't find me on CP, I'll be at Bob's HungOut
|
|
|
|
|
Hello, the codegurus around the world;)
There are many ways to get CWnd of view and doc.
1) Pass CWnd of CBanView of the constructor of your dialog.
2) GetParent() may work.
3) Get the frame's CWnd by AfxGetMainWnd() and use GetActiveView() of
CFrameWnd.
4) Create the static function like GetView().
(You can find this static function in somewhere of MSDN.)
CFrameWnd has GetAcitveDocument() or use inline GetDocuemt() in View class.
Please, don't send me your email about your questions directly.
Have a nice day!
Sonork - 100.10571:vcdeveloper
-Masaaki Onishi-
|
|
|
|
|
10x, both, i
managed to do it with
the static CMyDoc *MyDoc(); which
was described in a article in MSDN-a
|
|
|
|
|
I've got this ActiveX Object (made w/ VC++6.0), it creates a thread (so i can have multiple running at the same time), but it also fires events to my Visual Basic App. With me creating threads cause problems for those events trying to get back to the application?
It seems that way. VB seems to crash when i Fire an event. When i use an activex control, does it have its own thread? Can i redirect the thread ID or something like that? It's just being flat out weird. Has anyone had the same trouble before? I set up connection points at the beginning when i made the obj., is there any other settings that i need to have? Even a little bit of help will go a long way for me...Thanks Y'all.
~TIM!
SHABBA!!
|
|
|
|
|
template< typename T >
__forceinline T EPS( )
{
return 0;
}
template< >
__forceinline double EPS< double >( )
{
return DBL_EPSILON;
}
template< >
__forceinline double EPS< float >( )
{
return FLT_EPSILON;
}
template< typename T >
bool IsWorking( const T& r, T dEpsilon = EPS<t>( ) )
{
return true;
}
Is this is a valid C++ ?
I got "fatal error C1001: INTERNAL COMPILER ERROR" on MSVC
|
|
|
|
|
No, you can't make a template function where the only occurence of the template param is the return type. This is a limitation of MSVC. Change it to:
template<typename T> __forceinline T EPS( T* = NULL )
{
return 0;
} and change the other specializations accordingly to work around this limitation.
--Mike--
http://home.inreach.com/mdunn/
While I can't be correct on all matters, I can make the reassuring claim that where I am inaccurate, I am at least definitively inaccurate.
your with and
Sonork - 100.10414 AcidHelm
Test out a prerelease build of my Hotfix Checker v2.0! (1
|
|
|
|
|
No, this is not valid C++. It uses non C++ keywords.
I'd also add that MSVC is woefully inadequate when it comes to template handling. It can't handle more than the most basic use of templates. Function template specialization and partial template specialization it's especially bad at. Actually, function templates hardly work at all after sp3 (unless you're only instantiating one just one type/T.U.).
|
|
|
|
|
Is there a way to custom draw the slider control? I would like to change the color or even better, attach a bitmap to the control.. Anyone have any samples of code or know where I should start?
Thanks,
Rob
|
|
|
|
|
One way would be to subclass it and write your own OnPaint function. OnEraseBkgnd may help with a background image.
These are only ideas and I have not tested them, but that is where I would start.
Happy programming!!
|
|
|
|
|
Thanks.. I just found some articles on MSDN on how to custom draw a slider(track bar).. I'll do some looking into your idea and look at MSDN.. I have a bitmap in the back ground of my dialog so I like your idea of sub classing the sliders and erasing the background.. then I really wouldn't need to "skin" the slider (maybe just the knob).. Anyway, thanks for the reply!!
Rob
|
|
|
|
|
Sliders send NM_CUSTOMDRAW to their parent, like other common controls. With sliders you can custom-draw the thumb, the channel, and the tick marks. If you need a background to show through, subclass the slider and handle WM_ERASEBKGND.
--Mike--
http://home.inreach.com/mdunn/
While I can't be correct on all matters, I can make the reassuring claim that where I am inaccurate, I am at least definitively inaccurate.
your with and
Sonork - 100.10414 AcidHelm
Test out a prerelease build of my Hotfix Checker v2.0! (1
|
|
|
|
|
Hi
is there a way to avoid flickering in a list control if many items are inserted into the list control e.g. by a loop?
thanks in advance
modified 12-Sep-18 21:01pm.
|
|
|
|
|
Send a WM_SETREDRAW message, wParam=FALSE before your loop. After you're done, send it again with wParam=TRUE, then call InvalidateRect() to have the control redraw.
--Mike--
http://home.inreach.com/mdunn/
While I can't be correct on all matters, I can make the reassuring claim that where I am inaccurate, I am at least definitively inaccurate.
your with and
Sonork - 100.10414 AcidHelm
Test out a prerelease build of my Hotfix Checker v2.0! (1
|
|
|
|
|
Hi all, I`ve written some convolution code and managed to get the filters and stuff going fine, the only trouble is the speed! If I so much as use a vector once in the final nested for loop (where it works out the position of the filter with regards to the image) it slows the process down considerably (and I mean considerably - instead of being instant, theres at least a couple of seconds delay). In my code I *need* to access this memory bank at least three times in the final nested for loop (once for Red, Green Blue). Delphi has dynamic arrays which do the job perfectly, I was just wondering what the best way was in VC++? I`ve thought of using pointers, performing a small sum and accessing the pointer at that position, however I`d prefer to use the [] operator as it makes my code that little bit easier to read. Any ideas on better methods for quick access to retrieving data in memory, or as to why my bloody vectors are so slow (I'm using multidimensional vectors, 2-d ones, the location of which is stored in a vector, so I`m actually using a vector of a vector of a vector, but I didn`t think this should slow it down to the amount it is doing? Also my images are quite small, if used a large image I could probably make myself a cup of tea and drink it before it finished!!!) would be much appreciated. Thanks anyway guys,
Alan.
"When I left you I was but the learner, now I am the Master" - Darth Vader
|
|
|
|