예제 #1
0
void Imagen::blur(int k) {
    int i = 0;

    Pixel pixel_negro(0, 0, 0);

    Pixel2DContainer nuevo_pixels;

    Pixel1DContainer filaNegra(ancho(), pixel_negro);
    int iter = 0;
    while (iter < alto()) {
        nuevo_pixels.push_back(filaNegra);
        iter++;
    }

    int kVecCompletos = (2 * k - 1) * (2 * k - 1);
    while (i < alto()) {
        int j = 0;
        while (j < ancho()) {
            vector<Pixel> kVec = kVecinos(pixels, i, j, k);

            if(kVec.size() == kVecCompletos)
                nuevo_pixels[i][j] = promedio(kVec);
            else nuevo_pixels[i][j] = pixel_negro;

            j++;
        }

        i++;
    }

    pixels = nuevo_pixels;
}
예제 #2
0
vector<pair<int, int> > Imagen::posicionesMasOscuras() const {
    int colorMasOscuro = 255 * 3;

    vector<pair<int, int> > resultado;

    int i = 0;
    while (i < alto()) {
        int j = 0;
        while (j < ancho()) {
            Pixel estePixel = pixels[i][j];
            int colorPixel = estePixel.red() + estePixel.green() + estePixel.blue();

            if (colorPixel < colorMasOscuro) colorMasOscuro = colorPixel;

            j++;
        }
        i++;
    }


    i = 0;
    while (i < alto()) {
        int j = 0;
        while (j < ancho()) {
            Pixel estePixel = pixels[i][j];
            int colorPixel = estePixel.red() + estePixel.green() + estePixel.blue();

            if (colorPixel == colorMasOscuro) resultado.push_back(make_pair(i, j));
            j++;
        }
        i++;
    }

    return resultado;
}
예제 #3
0
ClutterBox2DJoint *
clutter_box2d_add_revolute_joint2 (ClutterBox2D        *box2d,
                                   ClutterActor        *actor1,
                                   ClutterActor        *actor2,
                                   const ClutterVertex *anchor)
{
    ClutterBox2DPrivate *priv;
    b2RevoluteJointDef jd;
    b2Body *bodyA, *bodyB;

    g_return_val_if_fail (CLUTTER_IS_BOX2D (box2d), NULL);
    g_return_val_if_fail (CLUTTER_IS_ACTOR (actor1), NULL);
    g_return_val_if_fail (CLUTTER_IS_ACTOR (actor2), NULL);
    g_return_val_if_fail (anchor != NULL, NULL);

    priv = box2d->priv;

    clutter_box2d_joint_ensure_bodies (box2d, actor1, actor2);

    jd.collideConnected = false;

    bodyA = clutter_box2d_get_child (box2d, actor1)->priv->body;
    bodyB = clutter_box2d_get_child (box2d, actor2)->priv->body;
    if (!bodyA || !bodyB)
        return NULL;

    b2Vec2 ancho  ( (anchor->x) * priv->scale_factor,
                    (anchor->y) * priv->scale_factor);

    jd.Initialize (bodyA, bodyB,
                   ancho);
    return joint_new (box2d, priv->world->CreateJoint (&jd), CLUTTER_BOX2D_JOINT_REVOLUTE);
}
예제 #4
0
void Imagen::guardar(std::ostream& os) const {
    os << alto() << " " << ancho() << " ";
    int i = 0;
    os << "[";
    while (i < alto()) {
        int j = 0;
        while (j < ancho()) {
            if(i != 0 || j != 0) os << ",";
            pixels[i][j].guardar(os);

            j++;
        }
        i++;
    }
    os << "]";
}
예제 #5
0
void A::imprimir() {
	char s1[10],s2[10];
	settextstyle (*datos[0], *datos[1], *datos [2]);
	outtextxy (0,0,cadena);
	itoa (altura(),s1,10);
	itoa (ancho(),s2,10);
	char *titulo;
	titulo = new char [strlen (s1) + strlen (s2) + 2];
	strcpy (titulo,s1);
	strcat (titulo," ");
	strcat (titulo,s2);
	outtextxy (200,200,titulo);
	delete titulo;
}
예제 #6
0
bool Imagen::operator==(const Imagen &otra) const {
    bool resultado = true;

    if(alto() != otra.alto() || ancho() != otra.ancho())
        resultado = false;
    else {
        int i = 0;
        while (i < alto()) {
            int j = 0;
            while (j < ancho()) {
                Pixel p1 = pixels[i][j];
                Pixel p2 = otra.obtenerPixel(i, j);
                if (p1.red() != p2.red() ||
                        p1.green() != p2.green() ||
                        p1.blue() != p2.blue())
                    resultado = false;
                j++;
            }
            i++;
        }
    }

    return resultado;
}