Click here to Skip to main content
15,921,837 members
Home / Discussions / C / C++ / MFC
   

C / C++ / MFC

 
GeneralRe: Device context problems Pin
mikewithersone15-Apr-04 12:47
mikewithersone15-Apr-04 12:47 
GeneralRe: Device context problems Pin
PJ Arends15-Apr-04 12:55
professionalPJ Arends15-Apr-04 12:55 
GeneralRe: Device context problems Pin
mikewithersone15-Apr-04 13:24
mikewithersone15-Apr-04 13:24 
GeneralRe: Device context problems Pin
PJ Arends15-Apr-04 13:39
professionalPJ Arends15-Apr-04 13:39 
GeneralRe: Device context problems Pin
mikewithersone15-Apr-04 13:46
mikewithersone15-Apr-04 13:46 
GeneralRe: Device context problems Pin
PJ Arends15-Apr-04 14:14
professionalPJ Arends15-Apr-04 14:14 
GeneralRe: Device context problems Pin
mikewithersone15-Apr-04 16:44
mikewithersone15-Apr-04 16:44 
Generalproblem trying to make a "FitAll" function to a ScrollView Pin
Stephane Routelous15-Apr-04 2:29
Stephane Routelous15-Apr-04 2:29 
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();//the original image
	if ( !dib )
		return;

	CDib* secondDib = pDoc->GetTransformedCDib();//the filtered image
	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));
	
	/*
	CRect edge(_BORDER-1,_BORDER-1,_BORDER+w+1,_BORDER+h+1);
	
	memDC.Draw3dRect(edge,RGB(0,0,0),RGB(255,255,255));
	edge += CSize(w+_BORDER,0);
	memDC.Draw3dRect(edge,RGB(0,0,0),RGB(255,255,255));
	*/
}

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

QuestionHow to change font of Labels in CDialog ? Pin
vgrigor15-Apr-04 2:25
vgrigor15-Apr-04 2:25 
AnswerRe: How to change font of Labels in CDialog ? Pin
Antony M Kancidrowski15-Apr-04 2:35
Antony M Kancidrowski15-Apr-04 2:35 
GeneralRe: How to change font of Labels in CDialog ? Pin
vgrigor15-Apr-04 2:42
vgrigor15-Apr-04 2:42 
AnswerRe: How to change font of Labels in CDialog ? Pin
Mike Dimmick15-Apr-04 2:43
Mike Dimmick15-Apr-04 2:43 
GeneralRe: How to change font of Labels in CDialog ? Pin
vgrigor15-Apr-04 2:49
vgrigor15-Apr-04 2:49 
GeneralRe: How to change font of Labels in CDialog ? Pin
Antony M Kancidrowski15-Apr-04 3:00
Antony M Kancidrowski15-Apr-04 3:00 
GeneralRe: How to change font of Labels in CDialog ? Pin
vgrigor15-Apr-04 3:06
vgrigor15-Apr-04 3:06 
GeneralRe: How to change font of Labels in CDialog ? Pin
Antony M Kancidrowski15-Apr-04 3:07
Antony M Kancidrowski15-Apr-04 3:07 
GeneralRe: How to change font of Labels in CDialog ? Pin
vgrigor15-Apr-04 3:11
vgrigor15-Apr-04 3:11 
GeneralInitializing CWinThread member Pin
Member 101882315-Apr-04 2:21
Member 101882315-Apr-04 2:21 
GeneralRe: Initializing CWinThread member Pin
David Crow15-Apr-04 2:51
David Crow15-Apr-04 2:51 
GeneralRe: Initializing CWinThread member Pin
Mike Dimmick15-Apr-04 2:56
Mike Dimmick15-Apr-04 2:56 
GeneralSerialize HANDLE Pin
Neha15-Apr-04 1:24
Neha15-Apr-04 1:24 
GeneralRe: Serialize HANDLE Pin
22491715-Apr-04 3:55
22491715-Apr-04 3:55 
GeneralRe: Serialize HANDLE Pin
22491715-Apr-04 4:13
22491715-Apr-04 4:13 
GeneralRe: Serialize HANDLE Pin
antlers15-Apr-04 11:35
antlers15-Apr-04 11:35 
GeneralProgrammatically changing an image in a dialog app Pin
Ashman15-Apr-04 1:19
Ashman15-Apr-04 1:19 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.