views:

34

answers:

1

Hi guys, I have an assignment using MFC which is a completely foreign language to me. I have to be able to upload Image1, and Image2 into 2 picture controls. And using a slider: when it is on the far left, you see Image1 in a third picture control, when it is on the far right you see Image2. Anywhere in between you should see a transition.

I have most of the assignment down, the only thing I have left is this transition. I have an idea of what I need to do and I'm using a function similar to Allegro. I just can't seem to find the syntax for MFC.

This is probably as wrong as it gets so any help at all would be appreciated enormously. Thanks!

I have:

int nPos = m_Slider.GetPos();
int nWidth1 = Image1.GetWidth();
int nHeight1 = Image1.GetHeight();
int nWidth2 = Image2.GetWidth();
int nHeight2 = Image2.GetHeight();
int nWidth3 = (nWidth1 +nWidth2)/2;
int nHeight3 = (nHeight1 + nHeight2)/2;
int nPixel1;
int nPixel2;
int nPixel3;
int i1, i2, i3, j1, j2, j3;
Image3.Create(nWidth3, nHeight3, 24);
for(i3=0; i3 < nWidth3; i3++){
 for(j3=0; j3 < nHeight3; j3++){
  i1 = i3 * nWidth1 / nWidth3;
  i2 = i3 * nWidth2 / nWidth3;
  j1 = j3 * nHeight1 / nHeight3;
  j2 = j3 * nHeight2 / nHeight3;
  getpixel(nPixel1, i1, j1);
  getpixel(nPixel2, i2, j2);
  putpixel(nPixel3, i3, j3);

  nPixel3 = (nPixel1 * (100-nPos) + nPixel2*nPos) *Image3.visible/100;
 }
}
A: 

You need a device context (DC) for the pictures and the transition. Load the pictures into the DC (you can do this in the background using a CMemDC), then you can calculate the transition and paint it into the third DC. The DC supports the functionality you want (GetPixel etc.)

dwo