sábado, 10 de mayo de 2014

Manipulacion de imagenes ,usando brush coppy y copyrect



Esta es una aplicacion realizada , utilizando los metodos de copyrect y brush copy,para simular el Zoom de la imagen, tambien utilizando los recorridos pixel a pixel de la imagen, y usando los operadores OR, AND , NOT para hacer unos cambios de color, usamos tambien las tecnicas de giro de imagenes para poder obtener los efectos de giro a la derecha, giro a la izquierda, 180º, 360º y tipo espejo.

Se le implemento tambien el uso de archivos para poder cargar la imagen desde cualquier lugar, como sucede con paint.

Les dejare parte del codigo para que lo puedan utilizar.

 //codigo para cargar imagen desde archivo, agregar previamete openDialog
        OpenDialog1->Execute();
       Image1->Visible=true;
       Image2->Visible=true;
       Image1->Picture->LoadFromFile(OpenDialog1->FileName);

//girar a la derecha 90 º la imagen
  for(int x=0; x<=Image1->Width; x++)

                for(int y=0;y <=Image1->Height; y++)
                {
                 Color=Image1->Canvas->Pixels[x][y];
                // GIRA 90º ala derecha
                 Image3->Canvas->Pixels[Image3->Width-y][x] = Color;
                 }

//girar a la izquierda 90 º la imagen
  for(int x=0; x<= Image1->Width; x++)

                for(int y=0;y <=Image1->Height; y++)
                {
                 Color=Image1->Canvas->Pixels[x][y];
                // GIRA 90º a la izquierda.

                 Image3->Canvas->Pixels[y][Image3->Height - x] = Color;
                }

  //EFECTO ESPEJO
 for(int x=0; x<Image1->Width; x++)

                for(int y=0;y < Image1->Height; y++)
                {
                 Color=Image1->Canvas->Pixels[x][y];

             
                 Image2->Canvas->Pixels[Image1->Width - x][y] = Color;
                 }
//cambio de color por rojo 255
 for(int x=0; x<Image1->Width;x++)
                for(int y=0; y<Image1->Height;y++)
                {
                    Color=Image1->Canvas->Pixels[x][y];
                    r1= Color & 255 ;//0xff
                    Image2->Canvas->Pixels[x][y] = r1;
                }

//recortar

   // variables tipo objeto
    TRect MyRect, MyOther;
               //x,  y
   //MyOther= Rect(535,10,200,350);
   MyOther= Rect(0, 0, Image2->Width/2, Image2->Height/2);
    MyRect= Rect(cx1,cy1,cx2,cy2);
   // crea objeto bitmap
    //Bitmap = new Graphics::TBitmap;
    // carga la imagen
   // Bitmap->LoadFromFile("C:/Users/orlando/Desktop/simp.bmp");

   //Form1->Canvas->CopyRect(MyOther, Bitmap->Canvas,MyRect);
    Image2->Canvas->CopyRect(MyOther, Image1->Canvas, MyRect);

// brush copy lo utilice para quitar el color seleccionado de la imagen
Graphics::TBitmap *Bitmap;
    // variables tipo objeto
    TRect MyRect, MyOther;

    MyRect = Rect(0,0,Image2->Width,Image2->Height);
    MyOther= Rect(0, 0, Image2->Width, Image2->Height);
    // crea objeto bitmap
    Bitmap = new Graphics::TBitmap;
    // carga la imagen
    Bitmap->LoadFromFile("C:/Users/orlando/Desktop/simp.bmp");

    //quita de la imagen alguno color en especifico o dado
    Image2->Canvas->BrushCopy(MyRect, Bitmap, MyRect,pixel);
    // borra bitmap
    delete Bitmap;

No hay comentarios:

Publicar un comentario