|
Iam currently developing a graphics application using ATL that requires me to directly manipulate each pixel of a display by using the setPixelV operator. The problem Iam having is that even tho Iam drawing well with in the PRCBounds RECT I appear to be getting some weird 'echos' across the display when I draw past a certain point. These echos appear to be replications of things ive already drawn else where on the display. See http://uk.geocities.com/richyroo@btinternet.com/problem.jpg for an example, ive drawn the PRCBounds RECT in so there is no question of drawing outside.
This problem does not occur in the activeX test container only in Internet explorer.
Iam convinced that this is a deviceContext problem but have no idea where to start to try and solve this problem? Any ideas please?
[] /\ () X
|
|
|
|
|
Try this article. http://www.codeproject.com/tools/imageviewer.asp[^]
I wrote that app for solving just the type of wierd drawing problems you are experiencing. Although I have never used it for ActiveX, I am quite sure it will help you find out if it is your code that is causing the problem.
Sonork 100.11743 Chicken Little
"You're obviously a superstar." - Christian Graus about me - 12 Feb '03
Within you lies the power for good - Use it!
|
|
|
|
|
Ive just tried using the viewer app but nothing appears! Ive followed all the instructions on the webpage? Can ou remember what where the causes of this crazy drawing thing last time you used it? Because iam completely clueless where to even begin? Iam drawing directly to the device context using setpixelV, should I be using a bitmap the using something like bitblt to transfer it to the device context?
[] /\ () X
|
|
|
|
|
Yes, you do have to use a memory DC to use the viewer app. A screen DC does not have a bitmap associated with it, so the viewer app can not display a bitmap that is not there.
What I have done in the past is throw the following code into my drawing code
SomeClass::OnDraw(CDC *pDC)
{
#ifdef VIEWER_ACTIVE
CRect rc;
GetClientRect(&rc);
CDC *pOriginalDC = pDC;
CDC TempDC;
TempDC.CreateCompatibleDC(pDC);
CBitmap Tempbmp;
Tempbmp.CreateCompatibleBitmap(pDC, rc.right, rc.bottom);
CBitmap *pOldbmp = (CBitmap *)TempDC.SelectObject(&Tempbmp);
TempDC.FillSolidRect(0,0,rc.right,rc.bottom,GetSysColor(COLOR_WINDOW));
pDC = &TempDC;
#endif
..
Your drawing code goes here, with calls to ShowDC(*pDC) where ever needed
..
#ifdef VIEWER_ACTIVE
pOriginalDC->BitBlt(0,0,rc.right,rc.bottom,pDC, 0, 0, SRCCOPY);
pDC->SelectObject(pOldbmp);
Tempbmp.DeleteObject();
pDC = pOriginalDC;
#endif And then, once I got it working properly, I could just remove the two #ifdef VIEWER_ACTIVE blocks.
Sonork 100.11743 Chicken Little
"You're obviously a superstar." - Christian Graus about me - 12 Feb '03
Within you lies the power for good - Use it!
|
|
|
|
|
Thanx ill give it ago, when u had this kind of problem, what was causing it and how did you resolve it?
[] /\ () X
|
|
|
|
|
The problem was in my code. Using the viewer app, and placing ShowDC's after ever drawing function, I was quickly able to see what part of my code was not doing what I thought it was supposed to do. The viewer app is just a great debugging tool, if I have to say so myself;P
Sonork 100.11743 Chicken Little
"You're obviously a superstar." - Christian Graus about me - 12 Feb '03
Within you lies the power for good - Use it!
|
|
|
|
|
LOL it seems like a good piece of kit, I just cant understand that my code works fine in teh activeX test container like this "http://uk.geocities.com/richyroo@btinternet.com/correct.jpg" and completly blows over in Internet explorer like this "http://uk.geocities.com/richyroo@btinternet.com/problem.jpg". I mean is there something I have to specify or do to get it displaying correctly in IE?! If I use other drawing methods such as drawRECT its fine but as soon as I play with setpixelV it blows?!
[] /\ () X
|
|
|
|
|
hmmm interesting problem.
I am not an Active-X expert (never use it ), I just thought I could help you with a tool to debug your drawing code.
Just a suggestion, have you tried double buffering???
If the problem is with IE then I am afraid i can not be of any help to you.
Sonork 100.11743 Chicken Little
"You're obviously a superstar." - Christian Graus about me - 12 Feb '03
Within you lies the power for good - Use it!
|
|
|
|
|
When I put that code into my onDraw() function (Which resides in the control header file in ATL) I just get a whole bunch of errors, saying that halfs the types are undeclared such as CRect & CBitmap?? Do I need to include some header file or something?
[] /\ () X
|
|
|
|
|
CRect and CBitmap are MFC classes. You are not using MFC so you should change them to plain old RECT and HBITMAPs instead.
Sonork 100.11743 Chicken Little
"You're obviously a superstar." - Christian Graus about me - 12 Feb '03
Within you lies the power for good - Use it!
|
|
|
|
|
Hey thanx I solved my problem now, i was writing directly to the DC which was causing problems, but now iam writing to a memDC with a bitmap then using bitBLT to switch it across to the actual DC. Thanx youve been a great help, hopefully ill get a better degree next months for it! Mike
[] /\ () X
|
|
|
|
|
Hi,
I'm developing an application where the user is applying filters to an image.
I have to display on the left side the original image and on the right side, the modified image.
I have an MDI application with a ScrollView derived view.
The image are draw in the view like that :
B Im Width B Im Width
|-|<--------->|-|<--------->|
BBBBBBBBBBBBBBBBBBBBBBBBBBBB
BBBOOOOOOOOOOOBBBFFFFFFFFFFF
BBBOOOOOOOOOOOBBBFFFFFFFFFFF
BBBOOOOOOOOOOOBBBFFFFFFFFFFF
BBBOOOOOOOOOOOBBBFFFFFFFFFFF
BBBOOOOOOOOOOOBBBFFFFFFFFFFF
BBBOOOOOOOOOOOBBBFFFFFFFFFFF
BBBOOOOOOOOOOOBBBFFFFFFFFFFF
where B is a border (set to 5 )
OOO : original image
FFF : filtered image
As member variable, I defined float m_zoomfactor; (set to 1 in the ctor ).
I defined 3 buttons in the toolbar : zoomin, zoomout, and fitall where :
void CTextureParameterizationControlView::OnZoomin()
{
m_zoomfactor*=2;
Invalidate();
}
void CTextureParameterizationControlView::OnZoomout()
{
m_zoomfactor*=.5;
Invalidate();
}
void CTextureParameterizationControlView::OnZoomfit()
{
CRect cr;
GetWindowRect(&cr);
float f1 = (float)(cr.Width()) / (float)(2*_BORDER + 2*m_width );
float f2 = (float)(cr.Height())/(float)(m_height+2*_BORDER+2);
m_zoomfactor = __min(f1,f2);
Invalidate();
}
here is my OnDraw method :
void CTextureParameterizationControlView::OnDraw(CDC* pDC)
{
CTextureParameterizationControlDoc* pDoc = GetDocument();
ASSERT_VALID(pDoc);
CDib* dib = pDoc->GetCDib();
if ( !dib )
return;
CDib* secondDib = pDoc->GetTransformedCDib();
if ( !secondDib )
secondDib = dib;
m_width = pDoc->m_imgInfo.m_width;
m_height = pDoc->m_imgInfo.m_height;
CSize sizeTotal;
sizeTotal.cx = 2*_BORDER + 2*m_width*m_zoomfactor;
sizeTotal.cy = m_height*m_zoomfactor+1*_BORDER;
SetScrollSizes(MM_TEXT, sizeTotal);
CMemDC memDC(pDC);
memDC.SetStretchBltMode(COLORONCOLOR);
CRect rect;
GetClientRect(&rect);
rect+=CSize(GetScrollPos(SB_HORZ),GetScrollPos(SB_VERT));
memDC.FillSolidRect(rect,RGB(200,200,200));
CRect rect2(_BORDER,_BORDER,m_width*m_zoomfactor+_BORDER,m_height*m_zoomfactor+_BORDER);
dib->Draw(&memDC,rect2,CPoint(0,0));
CRect rect3(2*_BORDER + m_width*m_zoomfactor,_BORDER,2*_BORDER + 2*m_width*m_zoomfactor,m_height*m_zoomfactor+_BORDER);
secondDib->Draw(&memDC,rect3,CPoint(0,0));
}
The problem that I have is that my OnZoomfit method doesn't work very good.
for small images (128x128), I have some place left on the right of the view. :
|BOOOBFFF | (| are the limits of the View)
for bigger images (1024x1024), the view is not fitted so that the right image has a part outside the view ( the scroll bar is available ). :
|BOOOBFF|F
Do you have an idea what can be wrong ?
Thanks in advance,
Stephane
www.exotk.org
|
|
|
|
|
I want to change font of static labels in CDialog,
to Bold
I think it need be dont in
OnCtlColor,
by getting font from CDC changing and SelectObject(font) from it.
But when I try toget current font as
CFont* pOldFont = pDC->SelectObject(&TmpFont);
that returns NULL;
But label is written by some font ?
How to get it?
And command to change ?
thanks
|
|
|
|
|
|
thanks you .
For not to make many classes -
does my version of working is not possible
or where incorrect?
|
|
|
|
|
You can simply send a WM_SETFONT message. However, the font object is not copied by the control - it uses the object handle you sent. You need to keep the object around at least as long as the control(s) which use it.
Stability. What an interesting concept. -- Chris Maunder
|
|
|
|
|
To whom I must send this message ?
To Label ?
|
|
|
|
|
I Mike means
1) Create a CFont object within the dialog (member variable).
2) Use GetDlgItem() to get the window of the static
3) Use SetFont() to set the font of the static object.
As long as the CFont item is there for the duration of the dialog it will be there for the duration of the dialogs controls.
This solution requires you to do all the work in the dialog.
Ant.
|
|
|
|
|
Thanks you.
Where to call it better ?
In OnInitDialog() ?
|
|
|
|
|
Yea InitDialog is fine
Ant.
|
|
|
|
|
|
why is it said not to initialize in cwinthread constructor but in InitInstance()..
|
|
|
|
|
Where is this "said?" Seeing it in context might help us to better understand what is meant.
"The pointy end goes in the other man." - Antonio Banderas (Zorro, 1998)
|
|
|
|
|
The constructor runs on whatever thread creates the CWinThread object (at the point the object is created). InitInstance runs on the thread itself once it has been started.
Typically there isn't much difference between the two, but things like Thread Local Storage will be affected. MFC uses a fair amount of Thread Local Storage internally.
Stability. What an interesting concept. -- Chris Maunder
|
|
|
|
|
Hi
How can I serialize the HANDLE?
Regards
Neha
|
|
|
|