|
That doesn't work...
I want to overload the appropriate operator such that I can call the following function:
ColourRGB interpolate(ColourRGB &c1, ColourRGB &c2, float pos);
like so:
UINT black(0x00000000);<br />
UINT white(0xFFFFFFFF);<br />
float temp = 0.0f;<br />
<br />
pixels[x][y] = interpolate(black, white, temp);
|
|
|
|
|
Why dont you call interpolate as a seperate function?
Величие не Бога может быть недооценена.
|
|
|
|
|
Sauce! wrote: I want to overload the appropriate operator such that I can call the following function:
ColourRGB interpolate(ColourRGB &c1, ColourRGB &c2, float pos);
You'll likely need to do this:
ColourRGB interpolate( ColourRGB c1, ColourRGB c2, float pos ) or make them const .
"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
|
|
|
|
|
Define a constructor for colourRGB that takes an int. So long as you don't mark it 'explicit', it's effectively a conversion operator.
Java, Basic, who cares - it's all a bunch of tree-hugging hippy cr*p
|
|
|
|
|
Hate to disappoint but I've already done that too
ColourRGB(const unsigned int &rhs);
When calling the function like so...
pixels[x][y] = interpolate(black, white, temp);
I still get the compile error "error C2664: 'interpolate' : cannot convert parameter 1 from 'UINT' to 'ColourRGB &'"
It compiles fine if I call the constructor explicitly but I'd like the conversion to be implicit.
|
|
|
|
|
ColourRGB(const unsigned int &rhs);
Try change above to below.
ColourRGB(const unsigned int rhs);
|
|
|
|
|
I still get the same error.
|
|
|
|
|
ColourRGB interpolate(ColourRGB &c1, ColourRGB &c2, float pos);
makes such compilation error.
But this may not;
ColourRGB interpolate(const ColourRGB &c1, const ColourRGB &c2, float pos);
for code pixels[x][y] = interpolate(0x00000000, 0xffffffff, pos);
|
|
|
|
|
How to use CListCtrl to handle message
|
|
|
|
|
|
Hi, all message can't be responsed?
how to handle?
|
|
|
|
|
Derive a class from CListCtrl and overide the WindowProc() function. All the message to the list control goes throught that function.
|
|
|
|
|
|
|
Please elaborate your question, we cannot understand until, you gave some more clue. Please refer the link to ask the correct way to get maximum answers [^]
Величие не Бога может быть недооценена.
|
|
|
|
|
thanks for all friends above;
I have a class derived CListCtrl, I tend to use this class to access the item associated with this class.
so I should use which message handle? all message can't be responded,why?
class CMyList : public CListCtrl
|
|
|
|
|
Hi Folks
I have tried load image using this ...
CImage img;
img.Load(_T("read.tif"));
Actully this is one full image .
but i need to cut in particular piece of that image.
image contains only two colors Black(RGB - 0 0 0) and white(RGB - 255 255 255)
i did only the load images ..but i dont know the further process what i can do??!!!!
Please help me !!!!!!!!11
Regards
~~~~~~~~~~~~~Raju~~~~~~~~~~~~~
|
|
|
|
|
You can use the Draw() function of the CImage to draw only a portion of the image. That is.
1. Create a memory dc
2. create a bitmap (createcompatiblebitmap() )
3. Select the bitmap to the dc.
4. Call CImage::Draw() funcion and pass the above created DC.
Now the bitmap that you created in step 2, will be having the image you want.
|
|
|
|
|
Thanks for your replay!!!!!!
void CImageReaderDlg::OnBnClickedButtonLoad()
{
CImage img;
img.Load(_T("read.tif"));
int nWidth=img.GetWidth();
int nHeight=img.GetHeight();
CClientDC dc(this);
CString str;
CPen ps;
for (double i=nWidth ; i > nWidth/2 ; i--)
{
for (double j=nHeight;j>nHeight/2;j--)
{
COLORREF clr=img.GetPixel(i,j);
int Rvalue=GetRValue(clr);
int Gvalue=GetGValue(clr);
int Bvalue=GetBValue(clr);
if(Rvalue == 255 && Gvalue == 255 && Bvalue == 255)
{
ps.CreatePen(PS_SOLID,i,RGB(255,0,0));
dc.SelectObject(&ps);
dc.MoveTo(i,j);
dc.LineTo(i,j);
}
}
}
}
its not drawing any colors in image ..what i can wrong here please suggest me !!
~~~~~~~~~~~~~Raju~~~~~~~~~~~~~
|
|
|
|
|
rajugis wrote: img.Load(_T("read.tif"));
Is the Load success? check the return value.
rajugis wrote: ps.CreatePen(PS_SOLID,i,RGB(255,0,0)); dc.SelectObject(&ps); dc.MoveTo(i,j); dc.LineTo(i,j);
Instead of the above, use SetPixel() function.
|
|
|
|
|
yes naveen ..its success .....
~~~~~~~~~~~~~Raju~~~~~~~~~~~~~
|
|
|
|
|
Any luck after using SetPixel() ?
|
|
|
|
|
i have another one prob ..
when come to the loop ...its showing debug assertion failed !!
and i dont know how to use setpixel function
please help me !!!!!!!!
~~~~~~~~~~~~~Raju~~~~~~~~~~~~~
|
|
|
|
|
rajugis wrote: when come to the loop ...its showing debug assertion failed !!
At which line? Press the retry button and see at which line assertion occured.
rajugis wrote: and i dont know how to use setpixel function
Well check MSDN[^]
|
|
|
|
|
Hi naveen
void CCBIView::OnDraw(CDC* pDC)
{
CCBIDoc* pDoc = GetDocument();
ASSERT_VALID(pDoc);
if (!pDoc)
return;
CImage image;
CPen ps;
image.Load (_T("read.tif"));
int w,h;
w = image.GetWidth();
h = image.GetHeight();
int color;
COLORREF clr;
for(int i = 0 ; i < w ; i ++)
for(int j = 0 ; j < h; j ++)
{
color = image.GetPixel(i,j);
clr=image.GetPixel(i,j);
int Rvalue=GetRValue(clr);
int Gvalue=GetGValue(clr);
int Bvalue=GetBValue(clr);
if(Rvalue == 0 && Gvalue == 0 && Bvalue == 0)
{
pDC ->SetPixel (i,j,color);
}
}
}
now its ok but too slow ...
and how to make one vertical and horizontal line in the image ..
PLease.....
~~~~~~~~~~~~~Raju~~~~~~~~~~~~~
|
|
|
|