Kamis, 28 Mei 2009

HISTOGRAM WARNA

TUGAS 2


Tombol 1 Untuk me-Load Gambar

void CPrak11_1Dlg::OnButton1()

{

// TODO: Add your control notification handler code here

static char BASED_CODE szFilter[]="Bitmap Files

(*.bmp)|*.bmp||";


CFileDialog m_ldFile(TRUE, "*.bmp", name,

OFN_HIDEREADONLY|OFN_OVERWRITEPROMPT, szFilter);

if(m_ldFile.DoModal()==IDOK)

{

name=m_ldFile.GetPathName();

}


CDC* pDC = m_pic1.GetDC();// mengarah kontrol picture

CDC dcMem; //mengarahkan obyek yg sdh dipilih pd bitmap

CRect rect;//kotak di picture

BITMAP bm;//mendefinisikan fungsi2 yg ada d bitmap

HBITMAP

hBitmap=(HBITMAP)::LoadImage(AfxGetInstanceHandle(),

name ,IMAGE_BITMAP, 0, 0,

LR_LOADFROMFILE|LR_CREATEDIBSECTION);

if(hBitmap)

{

if(m_bmpBitmap.DeleteObject())

m_bmpBitmap.Detach();

m_bmpBitmap.Attach(hBitmap);

}

m_pic1.GetClientRect(rect);//

m_bmpBitmap.GetBitmap(&bm);//

dcMem.CreateCompatibleDC(pDC);

//pDC->MoveTo(10,190);

//pDC->LineTo(300,190);

dcMem.SelectObject(&m_bmpBitmap);

pDC->StretchBlt(0,0,rect.Width(),rect.Height(),&dcMem,

0,0,bm.bmWidth,bm.bmHeight,SRCCOPY);

}