πŸš€ go-pugleaf

RetroBBS NetNews Server

Inspired by RockSolid Light RIP Retro Guy

Article View: chile.comp.programacion
Article #400

Re: Le pueden dar una miradita porfa ?

#400
From: Knock_
Date: Wed, 18 Feb 2009 20:16
149 lines
5180 bytes
Carlos G.P wrote:
> // watermarker 1.0 by Paul Blackburn (pawulb@gmail.com).
> 
> 
> #include <pngwriter.h>
> #include <stdlib.h>
> #include <string>
> #include <iostream>
> #include <fstream>
> using namespace std;
> 
> int main(int argc, char * argv[])
> {
>    if(argc != 4)
>      {
>     std::cout << "Wrong number of args (" << argc - 1 << "). Usage: ";
>     std::cout << "watermarker <config file> <UTF8 string file>";
>     std::cout << "<png image file>\n";
>     std::cout << "UTF8 string file should be a plain text or";
>     std::cout << "UTF8-formatted text file containing the copyright 
> string";
>     std::cout << "to be used. \nConfig file should be a text file 
> containing,";
>     std::cout << "on separate lines, \n";
>     std::cout << " pos_x;\n pos_y\n font_size\n blend coef.\n";
>     std::cout << " fontfile\n";
>     exit(1);
>      }
> 
>    // Get copyright string into a binary array.
>    char * copyrightfile = argv[2];
>    char * copyright;
>    long size;
>    ifstream file (copyrightfile, ios::in|ios::binary|ios::ate);
>    if (! file.is_open())
>      {
>     std::cout << "Error opening UTF8 text file."; exit (1);
>      }
>    size = file.tellg();
>    file.seekg (0, ios::beg);
>    copyright = new char [size];
>    file.read (copyright, size);
>    file.close();
> 
>    // Load configuration parameters.
>    std::ifstream params (argv[1]);
>    if (! params.is_open())
>      {
>     std::cout << "Error opening config file"; exit (1);
>      }
> 
>    string filename(argv[3]);
>    string fontfile;
>    int pos_x;
>    int pos_y ;
>    int font_size;
>    double angle;
>    double blend;
> 
>    params >> pos_x;
>    params >> pos_y;
>    params >> font_size;
>    params >> blend;
>    params >> fontfile;
>    params.close();
> 
>    // Create PNGwriter instance
>    pngwriter image(1,1,0,"caca.png");
>    image.readfromfile(filename.c_str());
> 
>    char * fn;
>    fn = new char[1024];
>    strcpy( fn, fontfile.c_str());
> 
>    double average;
>    int minx, miny, maxx, maxy;
>    average= 0.0;
>    angle = 1.57079633;
> 
>    minx = image.getwidth() - pos_x;
>    maxx = image.getwidth();
>    maxy = pos_y + image.get_text_width_utf8(fn, font_size, copyright);
>    miny = pos_y;
> 
>    // Calculate the average intensity of the image
>    // behind the text.
>    for(int xx=minx; xx <=maxx; xx++)
>      {
>     for(int yy=miny; yy <=maxy; yy++)
>       {
>          average = average + image.dread(xx,yy);
>       }
>      }
>    average = average/( (double)(  (maxx-minx)*(maxy-miny)    ));
>    std::cout << "Average image intensity in text area: " << average;
>    std::cout << ", Number of pixels taken: " <<  (maxx-minx)*(maxy-miny);
>    std::cout << ", text will be";
> 
>    // Plot the text on the image.
>    if(average>0.5)
>      {
>     std::cout << " black." <<std::endl;
>     image.plot_text_utf8_blend( fn, font_size,
>                     image.getwidth() - pos_x, pos_y,  angle,
>                     copyright,
>                     blend,
>                     0.0,  0.0,  0.0);
>      }
>    else
>      {
>     std::cout << " white." <<std::endl;
>     image.plot_text_utf8_blend( fn, font_size,
>                     image.getwidth() - pos_x, pos_y,  angle,
>                     copyright,
>                    blend,
>                     1.0,  1.0,  1.0);
>      }
> 
> 
> 
>    // Rename the file, add -wmk to the basename.
>    char * newfilename;
>    char fl[1024];
>    strcpy(fl, filename.c_str());
>    newfilename = strtok (fl, "." );
>    strcat(newfilename, "-wmk.png" );
>    image.pngwriter_rename(newfilename);
> 
>    image.settext(filename.c_str(), "Paul Blackburn",
>          "Copyright 2006 Paul Blackburn, paulwb AT gmail.com, All Rights 
> Reserved.",
>          "Watermaked with PNGwriter plus a small program called 
> watermarker.");
> 
>    // Write the PNG image to disk.
>    image.close();
> 
>    delete [] fn;
> 
>    return 0;
> }

y que quieres con esto ?, ya le echοΏ½ una mirada =)

Salu2,



Knock_
Technical Details
Message-ID: <gnhqbn$f8q$3@jagger.tie.cl>
Path: arc1-ca.pugleaf.net!g2news2.google.com!news1.google.com!news.glorb.com!news2.glorb.com!news.kjsl.com!news.nivel5.cl!news.tie.cl!not-for-mail
References: <glsck2$rht$1@news.nivel5.cl>

Show Full Headers
Complete Article Headers
X-Google-Thread: 1593cb,aaefd102ac708d0c
X-Google-Attributes: gid1593cb,domainid0,public,usenet
X-Google-Language: ENGLISH,ASCII
Path: arc1-ca.pugleaf.net!g2news2.google.com!news1.google.com!news.glorb.com!news2.glorb.com!news.kjsl.com!news.nivel5.cl!news.tie.cl!not-for-mail
From: Knock_ <knock@chile.com>
Newsgroups: chile.comp.programacion
Subject: Re: Le pueden dar una miradita porfa ?
Date: Wed, 18 Feb 2009 17:16:55 -0300
Organization: Telefonica Internet Empresa
Lines: 149
Message-ID: <gnhqbn$f8q$3@jagger.tie.cl>
References: <glsck2$rht$1@news.nivel5.cl>
NNTP-Posting-Host: 200-90-189-246.static.tie.cl
Mime-Version: 1.0
Content-Type: text/plain; charset=ISO-8859-1; format=flowed
Content-Transfer-Encoding: 8bit
X-Trace: jagger.tie.cl 1234988215 15642 200.90.189.246 (18 Feb 2009 20:16:55 GMT)
X-Complaints-To: news@jagger.tie.cl
NNTP-Posting-Date: Wed, 18 Feb 2009 20:16:55 +0000 (UTC)
User-Agent: Thunderbird 2.0.0.19 (Windows/20081209)
In-Reply-To: <glsck2$rht$1@news.nivel5.cl>