Tagging photo with problem

Asked

Viewed 83 times

3

I made a code to label a jpg, writing in the footer of the image the address of the customer’s website.

The Problem: Some photos the text is coming giant as if it was 72px font instead of 12px font

Link PHOTO CORRECT

Link INCORRECT PHOTO

Note that both photos are vertical, but the same text "www.sigasoftware.com.br" is in different size.

When running the VS debug apparently all values are similar, not justifying this font size, I need some hint of how I can try to find the problem

Follow part of the code of my class manipula_foto.cs

private void EstampaTexto(int _largura, int phHeight, Graphics grPhoto)
{
    Font crFont = null;
    SizeF crSize = new SizeF();

    crFont = new Font("verdana", 12, FontStyle.Bold);
    crSize = grPhoto.MeasureString(_textoetiqueta, crFont);

    //imagem a 5% da altura, debaixo para cima.
    int yPixlesFromBottom = (int)(phHeight * .05);

    // Agora que temos um tamanho de ponto usar a altura das cordas Copyrights
    // para determinar a coordenada y para desenhar a série de fotografia
    float yPosFromBottom = ((phHeight - 10) - (crSize.Height / 2));

    //Determinar a coordenada x calculando o centro da largura da imagem
    float xCenterOfImg = (_largura / 2);

    //definindo posição central do texto
    StringFormat StrFormat = new StringFormat();
    StrFormat.Alignment = StringAlignment.Center;

    // retangulo de fundo
    Brush brush = new SolidBrush(Color.FromArgb(120, 255, 255, 255));
    grPhoto.FillRectangle(brush, 0, yPosFromBottom, _largura, 20);

    //Texto Frente
    SolidBrush semiTransBrush = new SolidBrush(Color.FromArgb(153, 255, 255, 255));
    grPhoto.DrawString(_textoetiqueta,                 //string of text
        crFont,                                   //font
        semiTransBrush,                           //Brush
        new PointF(xCenterOfImg, yPosFromBottom),  //Position
        StrFormat);                               //Text alignment
}

2 answers

6


  • I think my font is in point (but new Font aparece family, float size, Fontstyle)

  • The example I used was http://msdn.microsoft.com/en-us/library/4kxs7tfz(v=vs.110). aspx

  • And it worked by making that example?

  • not yet...rs...

  • It’s just that now I can’t test Drawing, then I try.

3

Thanks to maniero’s response resolvi, putting the type of unit of measure used.

crFont = new Font("Arial", 12F, FontStyle.Bold, GraphicsUnit.Pixel);

Browser other questions tagged

You are not signed in. Login or sign up in order to post.