樹心幽徑

20170629setup ubuntu Boshiamy
2017/06/29,06:40

treehrt@treehrt-BM6AE-BM1AE-BP1AE:~$ sudo apt install fcitx-table-boshiamy

 

sudo dnf install ibus-rime


segX.c綠有道
2017/06/24,22:24

http://www.kmvs.km.edu.tw/lf/gallery/70/segxGreen.jpg

alt

//g++  `Magick++-config --cxxflags --cppflags` -I/usr/local/include/ImageMagick-7  segx.c `Magick++-config --ldflags --libs`  -L/usr/local/zlib/lib -lz
#include <stdio.h>
#include <string.h>
#include <stdlib.h>
#include <math.h>
#include <Magick++.h>
using namespace Magick;

void draw3(int ax,int ay,int bx,int by,int cx,int cy,int dx,int dy,Image *pim){
pim->strokeColor("green");
int px=(ax+bx)/2;
int py=(ay+by)/2;
pim->draw(DrawableLine(ax,ay,px,py));

int qx=(ax+cx)/2;
int qy=(ay+cy)/2;
pim->draw(DrawableLine(px,py,qx,qy));

int rx=(bx+cx)/2;
int ry=(by+cy)/2;
pim->draw(DrawableLine(qx,qy,rx,ry));

}

void drawA(int L,int ox,int oy,int w,int h,Image *pim)
{
draw3(ox+w*2/3,oy+h,ox,oy+h,ox,oy+h*1/3,ox+w*2/3,oy+h*1/3,pim);
draw3(ox,oy+h*2/3,ox,oy,ox+w*2/3,oy,ox+w*2/3,oy+h*2/3,pim);
draw3(ox+w*1/3,oy,ox+w,oy,ox+w,oy+h*2/3,ox+w*1/3,oy+h*2/3,pim);
draw3(ox+w,oy+h*1/3,ox+w,oy+h,ox+w*1/3,oy+h,ox+w*1/3,oy+h*1/3,pim);

if (L<1) {
    drawA(L+1,ox+w/3,oy+h/3,w/3,h/3,pim);
    drawA(L+1,ox+w/3,oy,w/3,h/3,pim);
    drawA(L+1,ox,oy+h/3,w/3,h/3,pim);
    drawA(L+1,ox+w/3,oy+h*2/3,w/3,h/3,pim);
    drawA(L+1,ox+w*2/3,oy+h/3,w/3,h/3,pim);
    }
}

void drawX(int L,int ox,int oy,int w,int h,Image *pim)
{
if (L==0) {
    drawA(0,ox,oy,w,h,pim); return;
    }
int dw,dh;
dw=w/2; dh=h/2; drawX(L-1,ox+dw,oy+dh,w/2,h/2,pim);
dw=0; dh=0; drawX(L-1,ox+dw,oy+dh,w/2,h/2,pim);
dw=w/2; dh=0; drawX(L-1,ox+dw,oy+dh,w/2,h/2,pim);
dw=0; dh=h/2; drawX(L-1,ox+dw,oy+dh,w/2,h/2,pim);
}

int main()
{
int w=2048/35;
int h=1536/35;
Image im( Geometry(w*35, h*35), Color("black"));
im.draw(DrawableStrokeColor(Color("black")));
im.strokeWidth(2);
drawX(4,0,0,35*w,35*h,&im);
char st[60];
sprintf(st,"w=%d h=%d",w,h);
im.font("/usr/share/fonts/truetype/arphic/uming.ttc");
im.fontPointsize(32);
im.draw(DrawableText(32, 32, st));
im.write("segx.jpg");
}

seg3.c version 2 ( Quadratic flake)
2017/06/21,21:39

alt

alt

//treehrt@hrt:~/lake$ g++  `Magick++-config --cxxflags --cppflags` -I/usr/local/include/ImageMagick-7  seg3.c `Magick++-config --ldflags --libs`  -L/usr/local/zlib/lib -lz

#include <stdio.h>
#include <string.h>
#include <stdlib.h>
#include <math.h>
#include <Magick++.h>
using namespace Magick;

void draw3(int ax,int ay,int bx,int by,int cx,int cy,int dx,int dy,Image *pim){


pim->strokeColor("blue"); 
int px=(ax+bx)/2;
int py=(ay+by)/2;
pim->draw(DrawableLine(ax,ay,px,py));

pim->strokeColor("red"); 
int qx=(ax+cx)/2;
int qy=(ay+cy)/2;
pim->draw(DrawableLine(px,py,qx,qy));

pim->strokeColor("green"); 
int rx=(bx+cx)/2;
int ry=(by+cy)/2;
pim->draw(DrawableLine(qx,qy,rx,ry));

}

void drawA(int L,int ox,int oy,int w,int h,Image *pim)
{
draw3(ox+w*2/3,oy+h,ox,oy+h,ox,oy+h*1/3,ox+w*2/3,oy+h*1/3,pim);
draw3(ox,oy+h*2/3,ox,oy,ox+w*2/3,oy,ox+w*2/3,oy+h*2/3,pim);
draw3(ox+w*1/3,oy,ox+w,oy,ox+w,oy+h*2/3,ox+w*1/3,oy+h*2/3,pim);
draw3(ox+w,oy+h*1/3,ox+w,oy+h,ox+w*1/3,oy+h,ox+w*1/3,oy+h*1/3,pim);

if (L<2) {
    drawA(L+1,ox+w/3,oy+h/3,w/3,h/3,pim);
    drawA(L+1,ox+w/3,oy,w/3,h/3,pim);
    drawA(L+1,ox,oy+h/3,w/3,h/3,pim);
    drawA(L+1,ox+w/3,oy+h*2/3,w/3,h/3,pim);
    drawA(L+1,ox+w*2/3,oy+h/3,w/3,h/3,pim);
    }
}

void drawB(int L,int ox,int oy,int w,int h,Image *pim)
{
drawA(L,ox+w*2/7,oy+h*2/7,w*3/7,h*3/7,pim);
drawA(L,ox,oy+h*3/7,w*3/7,h*3/7,pim);
drawA(L,ox+w/7,oy,w*3/7,h*3/7,pim);
drawA(L,ox+w*4/7,oy+h/7,w*3/7,h*3/7,pim);
drawA(L,ox+w*3/7,oy+h*4/7,w*3/7,h*3/7,pim);
}
int main()
{
int w=1024/15;
int h=768/15;

Image im( Geometry(w*15, h*15), Color("black"));
im.draw(DrawableStrokeColor(Color("black")));

im.strokeWidth(2);
drawB(0,4*w,4*h,w*7,h*7,&im);
drawB(0,0,h,w*7,h*7,&im);
drawB(0,7*w,0,w*7,h*7,&im);
drawB(0,8*w,7*h,w*7,h*7,&im);
drawB(0,w,8*h,w*7,h*7,&im);

char st[60];
sprintf(st,"w=%d h=%d",w,h);
im.font("/usr/share/fonts/truetype/arphic/uming.ttc");
im.fontPointsize(32);
im.draw(DrawableText(32, 32, st));
im.write("seg3.jpg");
}

seq3.c
2017/06/21,12:52

alt

//treehrt@hrt:~/lake$ g++  `Magick++-config --cxxflags --cppflags` -I/usr/local/include/ImageMagick-7  seg3.c `Magick++-config --ldflags --libs`  -L/usr/local/zlib/lib -lz
#include <stdio.h>
#include <string.h>
#include <stdlib.h>
#include <math.h>
#include <Magick++.h>
using namespace Magick;
void draw3(int ax,int ay,int bx,int by,int cx,int cy,int dx,int dy,Image *pim){
pim->strokeColor("blue"); 
int px=(ax+bx)/2;
int py=(ay+by)/2;
pim->draw(DrawableLine(ax,ay,px,py));

pim->strokeColor("red"); 
int qx=(ax+cx)/2;
int qy=(ay+cy)/2;
pim->draw(DrawableLine(px,py,qx,qy));

pim->strokeColor("green"); 
int rx=(bx+cx)/2;
int ry=(by+cy)/2;
pim->draw(DrawableLine(qx,qy,rx,ry));
}

void drawA(int L,int ox,int oy,int w,int h,Image *pim)
{
draw3(ox+w*2/3,oy+h,ox,oy+h,ox,oy+h*1/3,ox+w*2/3,oy+h*1/3,pim);
draw3(ox,oy+h*2/3,ox,oy,ox+w*2/3,oy,ox+w*2/3,oy+h*2/3,pim);
draw3(ox+w*1/3,oy,ox+w,oy,ox+w,oy+h*2/3,ox+w*1/3,oy+h*2/3,pim);
draw3(ox+w,oy+h*1/3,ox+w,oy+h,ox+w*1/3,oy+h,ox+w*1/3,oy+h*1/3,pim);
if (L<3) {
    drawA(L+1,ox+w/3,oy,w/3,h/3,pim);
    drawA(L+1,ox,oy+h/3,w/3,h/3,pim);
    drawA(L+1,ox+w/3,oy+h*2/3,w/3,h/3,pim);
    drawA(L+1,ox+w*2/3,oy+h/3,w/3,h/3,pim);
    }
}

int main()
{
int w=1024;
int h=768;

Image im( Geometry(w, h), Color("black"));
im.draw(DrawableStrokeColor(Color("black")));
im.strokeWidth(2);
int L=0;
drawA(L,0,0,w,h,&im);
char st[60];
sprintf(st,"w=%d h=%d",w,h);
im.font("/usr/share/fonts/truetype/arphic/uming.ttc");
im.fontPointsize(32);
im.draw(DrawableText(32, 32, st));
im.write("seg3.jpg");
}

20170619install_magicK (20171231setup revised)
2017/06/19,22:25


(1)download ImageMagick.tar.gz

https://www.imagemagick.org/script/install-source.php

(2)
treehrt@treehrt-BM6AE-BM1AE-BP1AE:~$ pwd
/home/treehrt
treehrt@treehrt-BM6AE-BM1AE-BP1AE:~$ tar xvzf ImageMagick.tar.gz

(3)
treehrt@treehrt-BM6AE-BM1AE-BP1AE:~$ cd ImageMagick-7.0.6-0/
treehrt@treehrt-BM6AE-BM1AE-BP1AE:~/ImageMagick-7.0.6-0$ ./configure
treehrt@treehrt-BM6AE-BM1AE-BP1AE:~/ImageMagick-7.0.6-0$ make
treehrt@treehrt-BM6AE-BM1AE-BP1AE:~/ImageMagick-7.0.6-0$ sudo make install
treehrt@treehrt-BM6AE-BM1AE-BP1AE:~/ImageMagick-7.0.6-0$ sudo ldconfig /usr/local/lib
treehrt@treehrt-BM6AE-BM1AE-BP1AE:~/ImageMagick-7.0.6-0$ /usr/local/bin/convert logo: logo.gif
treehrt@treehrt-BM6AE-BM1AE-BP1AE:~/ImageMagick-7.0.6-0$ make check

(4)
treehrt@treehrt-BM6AE-BM1AE-BP1AE:~$ wget http://prdownloads.sourceforge.net/libpng/libpng-1.6.29.tar.gz?download
treehrt@treehrt-BM6AE-BM1AE-BP1AE:~$ mv libpng-1.6.29.tar.gz\?download  libpng-1.6.29.tar.gz
treehrt@treehrt-BM6AE-BM1AE-BP1AE:~$ tar xvzf libpng-1.6.29.tar.gz
treehrt@treehrt-BM6AE-BM1AE-BP1AE:~$ cd libpng-1.6.29/
treehrt@treehrt-BM6AE-BM1AE-BP1AE:~/libpng-1.6.29$ ./configure
:
configure: error: zlib not installed


(5)
treehrt@treehrt-BM6AE-BM1AE-BP1AE:~$ wget https://zlib.net/zlib-1.2.11.tar.gz
treehrt@treehrt-BM6AE-BM1AE-BP1AE:~$ tar xvzf zlib-1.2.11.tar.gz
treehrt@treehrt-BM6AE-BM1AE-BP1AE:~$ cd zlib-1.2.11/
treehrt@treehrt-BM6AE-BM1AE-BP1AE:~/zlib-1.2.11$ ./configure
treehrt@treehrt-BM6AE-BM1AE-BP1AE:~/zlib-1.2.11$ make
treehrt@treehrt-BM6AE-BM1AE-BP1AE:~/zlib-1.2.11$ sudo make install

(6)
treehrt@treehrt-BM6AE-BM1AE-BP1AE:~/zlib-1.2.11$ cd ../libpng-1.6.29/
treehrt@treehrt-BM6AE-BM1AE-BP1AE:~/libpng-1.6.29$ ./configure

 

 ./configure --prefix=/usr LDFLAGS="-L/usr/local/lib -lz"

treehrt@treehrt-BM6AE-BM1AE-BP1AE:~/libpng-1.6.29$ make
treehrt@treehrt-BM6AE-BM1AE-BP1AE:~/libpng-1.6.29$ sudo make install

(7)
treehrt@treehrt-BM6AE-BM1AE-BP1AE:~$ tar xvzf freetype-2.8.tar.gz
treehrt@treehrt-BM6AE-BM1AE-BP1AE:~$ cd freetype-2.8/
treehrt@treehrt-BM6AE-BM1AE-BP1AE:~/freetype-2.8$ ./configure
:
Library configuration:
  external zlib: yes (pkg-config)
  bzip2:         no
  libpng:        yes (pkg-config)
  harfbuzz:      no

make: Nothing to be done for `unix'.
treehrt@treehrt-BM6AE-BM1AE-BP1AE:~/freetype-2.8$ make
treehrt@treehrt-BM6AE-BM1AE-BP1AE:~/freetype-2.8$ sudo make install


(12)
treehrt@treehrt-BM6AE-BM1AE-BP1AE:~/lake$ sudo apt-get install g++

(13)
treehrt@treehrt-BM6AE-BM1AE-BP1AE:~/lake$ sudo apt-get install libmagick++-dev

:
設定 libx11-doc (2:1.6.2-1ubuntu2) ...
Processing triggers for libc-bin (2.19-0ubuntu6.11) ...

(14)
treehrt@treehrt-BM6AE-BM1AE-BP1AE:~/ImageMagick-7.0.6-0$ ./configure
:
        X_CFLAGS        =
        X_PRE_LIBS      =  -lSM -lICE
        X_LIBS          =
        X_EXTRA_LIBS    =

  Options used to compile and link:
    PREFIX          = /usr/local
    EXEC-PREFIX     = /usr/local
    VERSION         = 7.0.6
    CC              = gcc -std=gnu99 -std=gnu99
    CFLAGS          = -I/usr/include/libxml2   -I/usr/local/include/libpng16   -pthread -I/usr/include/OpenEXR     -I/usr/include/lqr-1 -I/usr/include/glib-2.0 -I/usr/lib/i386-linux-gnu/glib-2.0/include     -I/usr/include/graphviz   -I/usr/local/include/freetype2 -I/usr/local/include -I/usr/local/include/libpng16   -I/usr/local/include/freetype2 -I/usr/local/include -I/usr/local/include/libpng16 -I/usr/include/freetype2   -pthread   -I/usr/local/include    -fopenmp -g -O2 -Wall -mtune=core-avx2 -fexceptions -pthread -DMAGICKCORE_HDRI_ENABLE=1 -DMAGICKCORE_QUANTUM_DEPTH=16
    CPPFLAGS        =   -DMAGICKCORE_HDRI_ENABLE=1 -DMAGICKCORE_QUANTUM_DEPTH=16
    PCFLAGS         =
    DEFS            = -DHAVE_CONFIG_H
    LDFLAGS         = 
    LIBS            =
    CXX             = g++
    CXXFLAGS        = -g -O2 -pthread
    FEATURES        = DPC HDRI Cipher OpenMP
    DELEGATES       = bzlib djvu mpeg fontconfig freetype jbig jng jpeg lcms lqr lzma openexr png ps tiff wmf x xml zlib
==============================================================================

treehrt@treehrt-BM6AE-BM1AE-BP1AE:~/ImageMagick-7.0.6-0$ sudo make install
:
I.pc Magick++/lib/Magick++.pc Magick++/lib/Magick++-7.Q16HDRI.pc '/usr/local/lib/pkgconfig'
make[2]: Leaving directory `/home/treehrt/ImageMagick-7.0.6-0'
make[1]: Leaving directory `/home/treehrt/ImageMagick-7.0.6-0'
treehrt@treehrt-BM6AE-BM1AE-BP1AE:~/lake$ sudo ldconfig /usr/local/lib

(15)20170823處理undefine refrence link問題

~/ImageMagick-7.0.6-0$ ./configure  --enable-shared

~/ImageMagick-7.0.6-0$ sudo make install

 

square.c
2017/06/19,13:55

alt

//treehrt@hrt:~/lake$ g++  `Magick++-config --cxxflags --cppflags` -I/usr/local/include/ImageMagick-7  square.c `Magick++-config --ldflags --libs`  -L/usr/local/zlib/lib -lz

#include <stdio.h>
#include <string.h>
#include <stdlib.h>
#include <math.h>
#include <Magick++.h>
using namespace Magick;

void innerRect(int L,int x1,int y1,int x2,int y2,int x3,int y3,int x4,int y4,Image *pim)
{
    printf("(%d,%d)- (%d,%d)-(%d,%d)-(%d,%d)-\n",x1,y1,x2,y2,x3,y3,x4,y4);
        int dx,dy;
        int ix1,ix2,ix3,ix4,iy1,iy2,iy3,iy4;

        dx=x2-x1;
        dy=y2-y1;
        ix1=x1+dx/4;iy1=y1+dy/4;

        dx=x3-x2;
        dy=y3-y2;
        ix2=x2+dx/4;iy2=y2+dy/4;

        dx=x4-x3;
        dy=y4-y3;
        ix3=x3+dx/4;iy3=y3+dy/4;

        dx=x1-x4;
        dy=y1-y4;
        ix4=x4+dx/4;iy4=y4+dy/4;

    pim->strokeColor("yellow"); 
    pim->draw(DrawableLine(ix1,iy1,ix2,iy2));

    pim->strokeColor("pink"); 
    pim->draw(DrawableLine(ix2,iy2,ix3,iy3));

    pim->strokeColor("blue"); 
    pim->draw(DrawableLine(ix3,iy3,ix4,iy4));

    pim->strokeColor("red"); 
    pim->draw(DrawableLine(ix4,iy4,ix1,iy1));
    if (L<18){
         innerRect(L+1,ix1,iy1,ix2,iy2,ix3,iy3,ix4,iy4,pim);
        }
}

int main()
{
int width=1024;
int height=768;

Image im( Geometry(width, height), Color("green"));
im.draw(DrawableStrokeColor(Color("black")));
im.strokeWidth(1);

int L=0;
innerRect(L,0,0,0,height,width,height,width,0,&im);

char st[60];
sprintf(st,"width=%d height=%d",width,height);
im.font("/usr/share/fonts/truetype/arphic/uming.ttc");
im.fontPointsize(32);
im.draw(DrawableText(32, 32, st));
im.write("square.jpg");
}

void utc2local(char *st1,char *st2,int dh)
2017/06/09,23:32

#include <stdio.h>
#include <stdlib.h>
#include <time.h>
void utc2local(char *st1,char *st2,int dh){
    time_t     utc,local;
    struct tm  ts,ts2;
    strptime(st1, "%Y-%m-%dT%H:%M:%S", &ts2);
    utc=mktime(&ts2);
    local=utc+dh*3600;
    ts = *localtime(&local);
    strftime(st2, 80, "%Y-%m-%dT%H:%M:%SZ", &ts);
}

int main(void)
{
    time_t     now;
    struct tm  ts,ts2;
    char       b1[80],b2[80];

    time(&now);
    ts = *localtime(&now);
    strftime(b1, sizeof(b1), "%a %Y-%m-%d %H:%M:%S %Z", &ts);
    printf("now localetime = %s\n", b1);

    char st[]="2017-03-31T23:09:15Z";
    utc2local(st,b2,+8);
    printf("utc %s   +%d --> local %s\n", st,+8,b2);
    return 0;
}

Tcard3.php
2017/06/05,10:31

[webadm@localhost wiki]$ cat Tcard3.php
<?php
/*
$h=1347; $w=2031;
$dw=$w/7; $dh=$h/7;
 $A=來源影像, 寬$wa  高$ha
 $B=目的影像, 寬$wb  高$hb
*/
$h=1347; $w=2031;
$dw=$w/9; $dh=$h/9;

$dw0=$dw/7; $dh0=$dh/7;
$dw1=$dw/9; $dh1=$dh/9;

require_once( 'includes/WebStart.php' );
define( 'MW_NO_SETUP', 1 );
define( 'MW_NO_OUTPUT_COMPRESSION', 1 );
require_once( 'includes/WebStart.php' );
wfProfileIn( 'thumb.php' );
wfProfileIn( 'thumb.php-start' );
require_once( "includes/GlobalFunctions.php" );
require_once( "includes/ImageFunctions.php" );

$wgTrivialMimeDetection = true; //don't use fancy mime detection, just check the file extension for jpg/gif/png.
require_once( "includes/StreamFile.php" );
require_once( "includes/AutoLoader.php" );
$csv=fopen('digit3.csv','r');
$c=0;
$array=fgetcsv($csv,100,":") ;
$bgR=$array[1];
$bgG=$array[2];
$bgB=$array[3];

while ($array=fgetcsv($csv,100,":") ) {
        $fileName[$c]="$array[1]";
        $hash = md5( $fileName[$c] );
        $dest[$c] = 'http://insecta.idv.tw/wiki/images/' . $hash{0} . '/' . substr( $hash, 0, 2 ) . '/' . urlencode($fileName[$c]) ;
        $c++;
        }
fclose($csv);

$csv=fopen('imageV3.txt','r');
$c=0;
while ($array=fgetcsv($csv,250,"|") ) {
        $fileName[$c]="$array[1]"; //檔名
        $Bstr4[$c]="$array[6]"; //地點
        $Bstr3[$c]="$array[2]$array[3]$array[4]$array[5]"; //年,月,日,縣
        $Bstr2[$c]="$array[10] $array[9] $array[7]"; // 目,科,種名
        $Bstr1[$c]="$array[8]"; // 學名
        $hash = md5( $fileName[$c] );
        $Bdest[$c] = 'http://insecta.idv.tw/wiki/images/' . $hash{0} . '/' . substr( $hash, 0, 2 ) . '/' . urlencode($fileName[$c]) ;
        $c++;
        }
fclose($csv);

$num=$_GET['num'];
$kind=$_GET['kind'];

$xx=($num-1)*4+$kind;

$ss="num=$num , kind=$kind , xx=$xx <br>\n";
$src_file=$Bdest[$xx-1];


header("Content-type:image/jpeg");
$A=ImageCreateFromJPEG($src_file);

switch($kind){
   case 1: $ccc=$dest[2]; break; //SpadeB.gif
   case 2: $ccc=$dest[1]; break; //HeartB.gif
   case 3: $ccc=$dest[3]; break; //DiamondB.gif
   case 4: $ccc=$dest[0] ;break; //ClubB.gif
   default: $ccc=$dest[2];;
}
$C1=ImageCreateFromGif($ccc);
switch($kind){
   case 1: $ccc=$dest[2+60]; break; //SpadeB.gif
   case 2: $ccc=$dest[1+60]; break; //HeartB.gif
   case 3: $ccc=$dest[3+60]; break; //DiamondB.gif
   case 4: $ccc=$dest[0+60] ;break; //ClubB.gif
   default: $ccc=$dest[2];;
}
$C2=ImageCreateFromGif($ccc);

if ($kind==1 || $kind==4) {
$D1=ImageCreateFromGif($dest[7+$num]);
$D2=ImageCreateFromGif($dest[7+13+$num]);
}
if ($kind==2 || $kind==3) {
$D1=ImageCreateFromGif($dest[7+$num+26]);
$D2=ImageCreateFromGif($dest[7+13+$num+26]);
}
if ($xx==53) {
$D1=ImageCreateFromGif($dest[4]);
$D2=ImageCreateFromGif($dest[5]);
}
if ($xx==54) {
$D1=ImageCreateFromGif($dest[6]);
$D2=ImageCreateFromGif($dest[7]);
}


$B=ImageCreateTrueColor($w,$h);
$a=ImageColorAllocate($B,$bgR,$bgG,$bgB);
$b=ImageColorAllocate($B,45,0,255);
$b2=ImageColorAllocate($B,104,0,195);
$b2=ImageColorAllocate($B,120,205,0);

$e=ImageColorAllocate($B,200,40,20);
$x1=1; $y1=1; $x2=$w-1; $y2=$h-1;
$wa=ImageSX($A);
$ha=ImageSY($A);
$ra=$wa/$ha;

$wb=$w-4*$dw;
$hb=$wb/$ra;
//int imagecopyresized(int dst_im, int src_im, int dstX, int dstY, int srcX, int srcY, int dstW, int dstH, int srcW, int srcH);
ImageCopyResized($B,$A,($w-$wb)/2,($h-$hb)/2,0,0,$wb,$hb,$wa,$ha);
imagefill($B,$x1+10,$y1+10,$a);

if ($kind<5) {
ImageCopyResized($B,$D2,$w-$dw-2*$dw0,0+2*$dh0,0,0,$dw,$dh,ImageSX($D1),ImageSY($D1));
ImageCopyResized($B,$C2,$w-$dw-8*$dw0+$dw/6,$dh-4*$dh0,0,0,$dw*2/3,$dh*2/3,ImageSX($C1),ImageSY($C1));
ImageCopyResized($B,$D1,2*$dw0,$h-$dh-2*$dh0,0,0,$dw,$dh,ImageSX($D2),ImageSY($D2));
ImageCopyResized($B,$C1,9*$dw0,$h-$dh-1*$dh0,0,0,$dw*2/3,$dh*2/3,ImageSX($C2),ImageSY($C2));
}
else {
ImageCopyResized($B,$D1,0+1.8*$dw0,0+1.5*$dh0,0,0,$dw,2*$dh,ImageSX($D1),ImageSY($D1));
ImageCopyResized($B,$D2,$w-$dw-1.5*$dw0,$h-2*$dh-1.8*$dh0,0,0,$dw,2*$dh,ImageSX($D2),ImageSY($D2));
}

ImageRectangle($B, $x1,$y1,$x2,$y2, $e);

$font = "/usr/share/fonts/cjkunifonts-ukai/ukai.ttf";

$sfile=$Bstr1[$xx-1];
//array imagettftext ( resource image, int size, int angle, int x, int y, int color, string fontfile, string text )
ImageTTFtext($B, 40, 90 , ($w+$wb)/2+0.2*$dw , ($h+$hb)/2-0.1*$dh, $b2, $font, $sfile);


$sfile=$Bstr2[$xx-1];
ImageTTFtext($B, 40, 90 , ($w+$wb)/2+0.5*$dw , ($h+$hb)/2-0.1*$dh, $b, $font, $sfile);

$sfile=$Bstr3[$xx-1];
ImageTTFtext($B, 40, 90 , ($w+$wb)/2+0.8*$dw , ($h+$hb)/2-0.1*$dh, $b, $font, $sfile);

$sfile=$Bstr4[$xx-1];
ImageTTFtext($B, 40, 90 , ($w+$wb)/2+1.1*$dw , ($h+$hb)/2-0.1*$dh, $b, $font, $sfile);
$sfile="台灣昆蟲維基館";
ImageTTFtext($B, 50, 90 , ($w-$wb)/2-0.3*$dw , 3*$h/4, $e, $font, $sfile);
ImageJPEG($B);
ImageDestroy($D1);
ImageDestroy($D2);
ImageDestroy($C1);
ImageDestroy($C2);
ImageDestroy($A);
ImageDestroy($B);
?>

magick++
2017/06/04,18:06

Image im( Geometry(width, height), Color(QuantumRange, QuantumRange, QuantumRange, 0));
im.strokeColor("red"); 
im.strokeWidth(2);
im.draw ( DrawableLine(10,10,width-10,height-10));
im.strokeColor("blue"); 
im.strokeWidth(1);
for (int i=1;i<c3-1;i++) {
    int ix1=(int)(pM[i+1].x67-min67x);
    int iy1=(int) height-(pM[i+1].y67-min67y);
    int ix2=(int)(pM[i+2].x67-min67x);
    int iy2=(int)height-(pM[i+2].y67-min67y);
    im.draw ( DrawableLine(ix1,iy1,ix2,iy2));
    }

im.write("1b.JPG");
}

 

DrawableFont font = DrawableFont("Helvetica Narrow",
                                  NormalStyle,
                                  400,
                                  SemiCondensedStretch
                                 );
text_draw_list.push_back(font);
text_draw_list.push_back(DrawableText(101, 50, "text to write on the canvas"));
text_draw_list.push_back(DrawableStrokeColor(Color("black")));
text_draw_list.push_back(DrawableFillColor(Color(0, 0, 0, MaxRGB)));

my_image.draw(text_draw_list);

 

Image my_image( Geometry(320,220), Color("white"));
// set the text rendering font (the color is determined by the "current" image setting)
my_image.font("-*-bitstream charter-medium-r-normal-*-*-*-*-*-*-*-iso8859-1");

my_image.annotate("NorthWest gravity annotation", NorthWestGravity);
my_image.annotate("SouthEast gravity annotation", SouthEastGravity);
my_image.annotate("Center gravity annotation", CenterGravity);

 

// Example:
Image my_image( Geometry(320,220), Color("white"));
list<Drawable> text_draw_list;
// set the text font: the font is specified via a string representing
// a fully qualified X font name (wildcards '*' are allowed)
text_draw_list.push_back(
DrawableFont("-misc-fixed-medium-o-semicondensed—13-*-*-*-c-60-iso8859-1"));
// set the text to be drawn at specified position: x=101, y=50 this case
text_draw_list.push_back( DrawableText(101, 50, "text to write on the canvas"));
// set the text color (the fill color must be set to transparent)
text_draw_list.push_back( DrawableStrokeColor(Color("black")));
text_draw_list.push_back( DrawableFillColor(Color(0, 0, 0, QuantumRange)));
// draw the "text to write on the canvas" string on the canvas with the above settings
my_image.draw( text_draw_list);
// Note: the red marking point in below image is located at position (100,50)

 

Image monimage("test.jpg"); // Draw a text with annotate monimage.font("@Arial"); monimage.boxColor("red"); monimage.backgroundColor("white"); monimage.fontPointsize( 72); monimage.strokeColor("black"); monimage.fillColor( "gold" ); monimage.annotate( "Text Sample with annotate", NorthGravity ); // Draw a text with draw monimage.draw(DrawableFont("@Arial")); monimage.draw(DrawableStrokeColor("black")); monimage.draw(DrawableFillColor(Color(0, 0, 0, MaxRGB))); monimage.draw(DrawableTextUnderColor("white")); monimage.draw(DrawableText(150,150,"Text Sample with draw")); // Draw a rectangle monimage.draw( Magick::DrawableRectangle(200,200, 270,170) ); monimage.write("resultat.jpg");

 


 
Accessible and Valid XHTML 1.0 Strict and CSS Powered by LifeType