コード例 #1
0
void Asteroids::CreateGUIResources()
{
    auto font = mGUI->Font();
    D3D11_TEXTURE2D_DESC textureDesc = CD3D11_TEXTURE2D_DESC(DXGI_FORMAT_A8_UNORM, font->BitmapWidth(), font->BitmapHeight(), 1, 1);

    D3D11_SUBRESOURCE_DATA initialData = {};
    initialData.pSysMem = font->Pixels();
    initialData.SysMemPitch = font->BitmapWidth();

    ID3D11Texture2D* texture = nullptr;
    ThrowIfFailed(mDevice->CreateTexture2D(&textureDesc, &initialData, &texture));
    ThrowIfFailed(mDevice->CreateShaderResourceView(texture, nullptr, &mFontTextureSRV));
    SafeRelease(&texture);

    // Load any GUI sprite textures
    for (size_t i = 0; i < mGUI->size(); ++i) {
        auto control = (*mGUI)[i];
        if (control->TextureFile().length() > 0 && mSpriteTextures.find(control->TextureFile()) == mSpriteTextures.end()) {
            std::wstring_convert<std::codecvt_utf8_utf16<wchar_t>> converter;            
            ID3D11ShaderResourceView* textureSRV = nullptr;
            ThrowIfFailed(CreateDDSTextureFromFile(mDevice, converter.from_bytes(control->TextureFile()).c_str(), &textureSRV, true));
            mSpriteTextures[control->TextureFile()] = textureSRV;
        }
    }
}
コード例 #2
0
ファイル: RenderWindow.cpp プロジェクト: fu7mu4/entonetics
////////////////////////////////////////////////////////////
/// Save the content of the window to an image
////////////////////////////////////////////////////////////
Image RenderWindow::Capture() const
{
    // Get the window dimensions
    const unsigned int Width  = GetWidth();
    const unsigned int Height = GetHeight();

    // Set our window as the current target for rendering
    if (SetActive())
    {
        // Get pixels from the backbuffer
        std::vector<Uint8> Pixels(Width * Height * 4);
        Uint8* PixelsPtr = &Pixels[0];
        GLCheck(glReadPixels(0, 0, Width, Height, GL_RGBA, GL_UNSIGNED_BYTE, PixelsPtr));

        // Flip the pixels
        unsigned int Pitch = Width * 4;
        for (unsigned int y = 0; y < Height / 2; ++y)
            std::swap_ranges(PixelsPtr + y * Pitch, PixelsPtr + (y + 1) * Pitch, PixelsPtr + (Height - y - 1) * Pitch);

        // Create an image from the pixel buffer and return it
        return Image(Width, Height, PixelsPtr);
    }
    else
    {
        return Image(Width, Height, Color::White);
    }
}
コード例 #3
0
ファイル: R2Image.C プロジェクト: acplus/peptalk
int R2Image::
WriteRAW(const char *filename) const
{
  // Open file
  FILE *fp = fopen(filename, "wb");
  if (!fp) {
    fprintf(stderr, "Unable to open raw image file %s", filename);
    return 0;
  }

  // Write header
  static const unsigned int magic = 54321;
  unsigned int header[4] = { magic, width, height, ncomponents };
  if (fwrite(header, sizeof(unsigned int), 4, fp) != 4) {
    fprintf(stderr, "Unable to write header to raw image file %s", filename);
    return 0;
  }

  // Allocate buffer
  float *buf = new float [ width ];
  if (!buf) {
    fprintf(stderr, "Unable to allocate buffer for raw image file %s", filename);
    return 0;
  }

  // Write data for each component
  for (int i = 0; i < ncomponents; i++) {
    for (int j = 0; j < height; j++) {
      // Load buffer
      const unsigned char *pixelsp = Pixels(j);
      for (int k = 0; k < width; k++) {
        for (int c = 0; c < i; c++) pixelsp++;
        buf[k] = *(pixelsp++) / 255.0F;
        for (int c = i+1; c < ncomponents; c++) pixelsp++;
      }

      // Write buffer
      if (fwrite(buf, sizeof(float), width, fp) != (unsigned int) width) {
        fprintf(stderr, "Unable to write data to raw image file %s", filename);
        return 0;
      }
    }
  }

  // Free buffer
  delete [] buf;

  // Close file
  fclose(fp);

  // Return number of bytes written
  return width * height * ncomponents * sizeof(float);  
}
コード例 #4
0
ファイル: R2Image.C プロジェクト: acplus/peptalk
int R2Image::
WriteTIFF(const char *filename) const
{
#ifndef OMIT_TIFF
  // Open TIFF file
  TIFF *out = TIFFOpen(filename, "w");
  if (!out) {
    fprintf(stderr, "Unable to open TIFF file %s\n", filename);
    return 0;
  }

  // Set TIFF parameters
  TIFFSetField(out, TIFFTAG_IMAGEWIDTH, width);
  TIFFSetField(out, TIFFTAG_IMAGELENGTH, height);
  TIFFSetField(out, TIFFTAG_ORIENTATION, ORIENTATION_BOTLEFT);
  TIFFSetField(out, TIFFTAG_SAMPLESPERPIXEL, 3);
  TIFFSetField(out, TIFFTAG_BITSPERSAMPLE, 8);
  TIFFSetField(out, TIFFTAG_PLANARCONFIG, PLANARCONFIG_CONTIG);
  TIFFSetField(out, TIFFTAG_PHOTOMETRIC, PHOTOMETRIC_RGB);
  TIFFSetField(out, TIFFTAG_COMPRESSION, COMPRESSION_NONE);
  TIFFSetField(out, TIFFTAG_ROWSPERSTRIP, 1);

  // Allocate data for scan lines
  int scanline_size = TIFFScanlineSize(out);
  unsigned char *buf = (unsigned char *)_TIFFmalloc(scanline_size);
  if (!buf) {
    fprintf(stderr, "Unable to allocate memory for TIFF scan lines\n");
    return 0;
  }

  // Write scan lines to TIFF file
  for (int row = 0; row < height; row++) {
    const unsigned char *p = Pixels(row);
    if (TIFFWriteScanline(out, (tdata_t) p, height - row - 1, 0) < 0) {
      fprintf(stderr, "Unable to write scanline to TIFF image %s\n", filename);
      return 0;
    }
  }

  // Free data for scan lines
  _TIFFfree(buf);

  // Close TIFF file
  TIFFClose(out);

  // Return number of bytes written
  return 1;
#else
  RNFail("TIFF not supported");
  return 0;
#endif
}
コード例 #5
0
ファイル: automaptexture.cpp プロジェクト: coelckers/gzdoom
TArray<uint8_t> FAutomapTexture::CreatePalettedPixels(int conversion)
{
	int x, y;
	FMemLump data = Wads.ReadLump (SourceLump);
	const uint8_t *indata = (const uint8_t *)data.GetMem();

	TArray<uint8_t> Pixels(Width * Height, true);

	const uint8_t *remap = ImageHelpers::GetRemap(conversion == luminance);
	for (x = 0; x < Width; ++x)
	{
		for (y = 0; y < Height; ++y)
		{
			auto p = indata[x + 320 * y];
			Pixels[x*Height + y] = remap[p];
		}
	}
	return Pixels;
}
コード例 #6
0
void Image_EGA_BytePlanar::doConversion()
{
	this->content->seekg(this->offset, stream::start);

	auto dims = this->dimensions();
	this->pixels = Pixels(dims.x * dims.y, '\x00');
	this->mask = Pixels(dims.x * dims.y, '\x00');

	auto imgData = &this->pixels[0];
	auto maskData = &this->mask[0];
	for (unsigned int y = 0; y < dims.y; y++) {
		// Run through each lot of eight pixels (a "cell"), including a partial
		// cell at the end if the width isn't a multiple of 8.
		for (unsigned int x = 0; x < dims.x; x += 8) {

			for (auto p : this->planes) {
				if (p == EGAPlanePurpose::Unused) break;

				bool doMask = false, swap = false;
				uint8_t value = 0;
				switch (p) {
					case EGAPlanePurpose::Unused: continue;
					case EGAPlanePurpose::Blank:      doMask = false; value = 0x00; swap = false; break;
					case EGAPlanePurpose::Blue0:      doMask = false; value = 0x01; swap = true;  break;
					case EGAPlanePurpose::Blue1:      doMask = false; value = 0x01; swap = false; break;
					case EGAPlanePurpose::Green0:     doMask = false; value = 0x02; swap = true;  break;
					case EGAPlanePurpose::Green1:     doMask = false; value = 0x02; swap = false; break;
					case EGAPlanePurpose::Red0:       doMask = false; value = 0x04; swap = true;  break;
					case EGAPlanePurpose::Red1:       doMask = false; value = 0x04; swap = false; break;
					case EGAPlanePurpose::Intensity0: doMask = false; value = 0x08; swap = true;  break;
					case EGAPlanePurpose::Intensity1: doMask = false; value = 0x08; swap = false; break;
					case EGAPlanePurpose::Hit0:       doMask = true;  value = (uint8_t)Mask::Touch;       swap = true;  break;
					case EGAPlanePurpose::Hit1:       doMask = true;  value = (uint8_t)Mask::Touch;       swap = false; break;
					case EGAPlanePurpose::Opaque0:    doMask = true;  value = (uint8_t)Mask::Transparent; swap = false; break;
					case EGAPlanePurpose::Opaque1:    doMask = true;  value = (uint8_t)Mask::Transparent; swap = true;  break;
				}

				uint8_t nextByte;
				try {
					*this->content >> u8(nextByte);
				} catch (const stream::incomplete_read&) {
					std::cerr << "ERROR: Incomplete read converting image to standard "
						"format.  Returning partial conversion." << std::endl;
					return;
				}

				// See which bit we should read down to (starting at 7.)  This is only
				// used when the image is not an even multiple of 8.
				int bits = 0;
				if (x + 8 > dims.x) bits = 8 - (dims.x % 8);

				// Run through all the (valid) bits in this byte
				auto rowData = doMask ? maskData : imgData;
				for (int b = 7; b >= bits; b--) {
					*rowData++ |= (((nextByte >> b) & 1) ^ swap) ? value : 0x00;
				}
			}
			int lenCell = 8;
			if (x + 8 > dims.x) lenCell = dims.x - x;
			imgData += lenCell;
			maskData += lenCell;
		}
	}
	return;
}
コード例 #7
0
ファイル: DateAdjustDlg.cpp プロジェクト: mikekov/ExifPro
BOOL DateAdjustDlg::InitDlg()
{
	if (photos_.empty())
	{
		EndDialog(IDCANCEL);
		return true;
	}

	adj_mode_ = profile_adj_mode_;
	days_ = profile_days_;
	hours_ = profile_hours_;
	minutes_ = profile_minutes_;
	seconds_ = profile_seconds_;

	DialogChild::OnInitDialog();

	SetDlgItemInt(IDC_DAYS, days_);
	SetDlgItemInt(IDC_HOURS, hours_);
	SetDlgItemInt(IDC_MINUTES, minutes_);
	SetDlgItemInt(IDC_SECONDS, seconds_);

	BuildResizingMap();
	SetWndResizing(IDC_LIST, DlgAutoResize::RESIZE);
	SetWndResizing(IDC_HELP_BTN, DlgAutoResize::MOVE_V);
	SetWndResizing(IDCANCEL, DlgAutoResize::MOVE);
	SetWndResizing(IDOK, DlgAutoResize::MOVE);

	results_.SetExtendedStyle(LVS_EX_FULLROWSELECT | LVS_EX_DOUBLEBUFFER | LVS_EX_LABELTIP);
	//results_.InsertColumn(0, _T("File Name"), LVCFMT_LEFT, 100);
	results_.InsertColumn(0, _T("Existing Date/Time"), LVCFMT_LEFT, Pixels(150));
	results_.InsertColumn(1, _T("New Date/Time"), LVCFMT_LEFT, Pixels(150));
	results_.SetItemCount(static_cast<int>(photos_.size()));

	time_edit_.ModifyStyle(0, DTS_TIMEFORMAT);

	SubclassHelpBtn(_T("ToolDateTime.htm"));

	spin_days_.SetRange32(-100000, 100000);
	spin_hours_.SetRange32(-1000000, 1000000);
	spin_minutes_.SetRange32(-10000000, 10000000);
	spin_seconds_.SetRange32(-2000000000, 2000000000);

	// some reasonable text length limits (include sign, digits, and thousand separators)
	edit_days_.SetLimitText(8);
	edit_hours_.SetLimitText(16);
	edit_minutes_.SetLimitText(16);
	edit_seconds_.SetLimitText(16);

	// set min/max date
	WPARAM flags= GDTR_MIN | GDTR_MAX;
	SYSTEMTIME sys[2];
	memset(sys, 0, sizeof(sys));
	sys[0].wYear = 1601;
	sys[0].wMonth = 1;
	sys[0].wDay = 2;
	sys[1].wYear = 9999;
	sys[1].wMonth = 12;
	sys[1].wDay = 31;
	date_edit_.SendMessage(DTM_SETRANGE, flags, reinterpret_cast<LPARAM>(sys));
	time_edit_.SendMessage(DTM_SETRANGE, flags, reinterpret_cast<LPARAM>(sys));

	auto dt= DateTimeToSytemTime(FromISOString(profile_date_time_));
	DateTime_SetSystemtime(date_edit_, GDT_VALID, &dt);
	DateTime_SetSystemtime(time_edit_, GDT_VALID, &dt);

	example_time_ = photos_.front()->GetDateTime();

	ready_ = true;

	EnableGroup(adj_mode_ == 0);

	UpdateExampleAndOkBtn();

	return TRUE;  // return TRUE unless you set the focus to a control
	              // EXCEPTION: OCX Property Pages should return FALSE
}
コード例 #8
0
ファイル: R2Image.C プロジェクト: acplus/peptalk
int R2Image::
ReadRAW(const char *filename)
{
  // Open file
  FILE *fp = fopen(filename, "rb");
  if (!fp) {
    fprintf(stderr, "Unable to open raw image file %s", filename);
    return 0;
  }

  // Read header
  unsigned int header[4];
  if (fread(header, sizeof(unsigned int), 4, fp) != 4) {
    fprintf(stderr, "Unable to read header to raw image file %s", filename);
    return 0;
  }

  // Check magic number
  static const unsigned int magic = 54321;
  if (header[0] != magic) {
    fprintf(stderr, "Invalid header in raw image file %s", filename);
    return 0;
  }

  // Parse header
  width = header[1];
  height = header[2];
  ncomponents = header[3];
  rowsize = ncomponents * width;
  if ((rowsize % 4) != 0) rowsize = (rowsize / 4 + 1) * 4;

  // Allocate image pixels
  int nbytes = rowsize * height;
  pixels = new unsigned char [nbytes];
  if (!pixels) {
    fprintf(stderr, "Unable to allocate memory for RAW file");
    return 0;
  }

  // Allocate buffer
  float *buf = new float [ width ];
  if (!buf) {
    fprintf(stderr, "Unable to allocate buffer for raw image file %s", filename);
    return 0;
  }

  // Read data for each component
  for (int i = 0; i < ncomponents; i++) {
    for (int j = 0; j < height; j++) {
      // Read buffer for one row
      if (fread(buf, sizeof(float), width, fp) != (unsigned int) width) {
        fprintf(stderr, "Unable to read data from raw image file %s", filename);
        return 0;
      }

      // Parse row
      unsigned char *pixelsp = (unsigned char *) Pixels(j);
      for (int k = 0; k < width; k++) {
        for (int c = 0; c < i; c++) pixelsp++;
        *(pixelsp++) = (int) (buf[k] * 255);
        for (int c = i+1; c < ncomponents; c++) pixelsp++;
      }
    }

  }

  // Free buffer
  delete [] buf;

  // Close file
  fclose(fp);

  // Return number of bytes read
  return width * height * ncomponents * sizeof(float);  
}
コード例 #9
0
TArray<uint8_t> FMultiPatchTexture::CreatePalettedPixels(int conversion)
{
	int numpix = Width * Height;
	uint8_t blendwork[256];
	bool buildrgb = bComplex;

	TArray<uint8_t> Pixels(numpix, true);
	memset (Pixels.Data(), 0, numpix);

	if (conversion == luminance)
	{
		// For alpha textures, downconversion to the palette would lose too much precision if not all patches use the palette.
		buildrgb = !UseGamePalette();
	}
	else
	{
		// For regular textures we can use paletted compositing if all patches are just being copied because they all can create a paletted buffer.
		if (!buildrgb) for (int i = 0; i < NumParts; ++i)
		{
			if (Parts[i].op != OP_COPY)
			{
				buildrgb = true;
			}
		}
	}
	if (conversion == noremap0)
	{
		// sky remapping will only happen if
		// - the texture was defined through a TEXTUREx lump (this implies only trivial copies)
		// - all patches use the base palette.
		// All other cases would not be able to properly deal with this special case.
		// For textual definitions this hack isn't necessary.
		if (bTextual || !UseGamePalette()) conversion = normal;
	}

	if (!buildrgb)
	{	
		for (int i = 0; i < NumParts; ++i)
		{
			uint8_t *trans = Parts[i].Translation? Parts[i].Translation->Remap : nullptr;
			{
				if (Parts[i].Blend != 0)
				{
					trans = GetBlendMap(Parts[i].Blend, blendwork);
				}
				CopyToBlock (Pixels.Data(), Width, Height, Parts[i].Image, Parts[i].OriginX, Parts[i].OriginY, Parts[i].Rotate, trans, conversion);
			}
		}
	}
	else
	{
		// In case there are translucent patches let's do the composition in
		// True color to keep as much precision as possible before downconverting to the palette.
		FBitmap PixelsIn;
		PixelsIn.Create(Width, Height);
		CopyPixels(&PixelsIn, normal);
		for(int y = 0; y < Height; y++)
		{
			uint8_t *in = PixelsIn.GetPixels() + Width * y * 4;
			uint8_t *out = Pixels.Data() + y;
			for (int x = 0; x < Width; x++)
			{
				if (*out == 0 && in[3] != 0)
				{
					*out = ImageHelpers::RGBToPalette(conversion == luminance, in[2], in[1], in[0]);
				}
				out += Height;
				in += 4;
			}
		}
	}
	return Pixels;
}
コード例 #10
0
ファイル: extract.cpp プロジェクト: floft/freetron
Pixels readPDFImage(PoDoFo::PdfObject* object, const PixelType type,
    const ColorSpace colorspace, const PoDoFo::pdf_int64 componentbits,
    const std::string& filename, Form& form)
{
    Pixels pixels;

    if (!object->GetDictionary().HasKey(PoDoFo::PdfName("Width")) ||
        !object->GetDictionary().HasKey(PoDoFo::PdfName("Height")))
        return pixels;

    const unsigned int width  = object->GetDictionary().GetKey(PoDoFo::PdfName("Width"))->GetNumber();
    const unsigned int height = object->GetDictionary().GetKey(PoDoFo::PdfName("Height"))->GetNumber();

    if (type == PixelType::JPG)
    {
        PoDoFo::PdfMemStream* stream = dynamic_cast<PoDoFo::PdfMemStream*>(object->GetStream());
        pixels = Pixels(IL_JPG, stream->Get(), stream->GetLength(), filename);
    }
    else if (type == PixelType::TIF)
    {
        // Monochrome, otherwise wouldn't have used CCITT
        const unsigned int bits = 1;
        const unsigned int samples = 1;

        if (bits != componentbits)
            form.log("BitsPerComponent is not 1 for CCITTFaxDecode image in PDF", LogType::Warning);

        std::ostringstream os;
        TIFF* tif = TIFFStreamOpen("Input", &os);
        TIFFSetField(tif, TIFFTAG_IMAGEWIDTH,       width);
        TIFFSetField(tif, TIFFTAG_IMAGELENGTH,      height);
        TIFFSetField(tif, TIFFTAG_BITSPERSAMPLE,    bits);
        TIFFSetField(tif, TIFFTAG_SAMPLESPERPIXEL,  samples);
        TIFFSetField(tif, TIFFTAG_FILLORDER,        FILLORDER_MSB2LSB);
        TIFFSetField(tif, TIFFTAG_PLANARCONFIG,     PLANARCONFIG_CONTIG);
        TIFFSetField(tif, TIFFTAG_PHOTOMETRIC,      PHOTOMETRIC_MINISWHITE);
        TIFFSetField(tif, TIFFTAG_XRESOLUTION,      204.0); // From fax2tiff
        TIFFSetField(tif, TIFFTAG_YRESOLUTION,      196.0); // ditto
        TIFFSetField(tif, TIFFTAG_RESOLUTIONUNIT,   RESUNIT_INCH);
        TIFFSetField(tif, TIFFTAG_COMPRESSION,      COMPRESSION_CCITTFAX4);
        TIFFSetField(tif, TIFFTAG_ORIENTATION,      ORIENTATION_TOPLEFT);
        TIFFSetField(tif, TIFFTAG_FAXMODE,      FAXMODE_CLASSF);
        TIFFSetField(tif, TIFFTAG_ROWSPERSTRIP,     (uint32)-1L);

        // stream->Get returns read-only, so copy it
        PoDoFo::PdfMemStream* stream = dynamic_cast<PoDoFo::PdfMemStream*>(object->GetStream());
        const char* readonly = stream->Get();
        PoDoFo::pdf_long len = stream->GetLength();
        char* buffer = new char[len];
        std::memcpy(buffer, readonly, len);

        TIFFWriteRawStrip(tif, 0, buffer, len);
        TIFFWriteDirectory(tif);
        TIFFClose(tif);

        delete[] buffer;

        pixels = Pixels(IL_TIF, os.str().c_str(), os.tellp(), filename);
    }
    else
    {
        std::ostringstream os;

        // P4 is bitmap (1 bit), P5 is graymap (8 bit), P6 is pixmap (24 bit or
        // 8-bit/channel). See:
        // http://netpbm.sourceforge.net/doc/pbm.html
        // http://en.wikipedia.org/wiki/Portable_anymap#File_format_description
        if (colorspace == ColorSpace::Gray)
            os << ((componentbits == 1)?"P4\n":"P5\n");
        else
            os << "P6\n";

        os << width  << " "
           << height << "\n";

        if (componentbits != 1)
           os << "255\n";

        std::string s = os.str();

        char* buffer;
        PoDoFo::pdf_long len;

        object->GetStream()->GetFilteredCopy(&buffer, &len);

        // Warn if unknown colorspace
        if (colorspace == ColorSpace::Unknown)
            form.log("unknown color space on PDF image", LogType::Warning);

        // If the buffer isn't the correct size for the image data, don't try
        // reading the image from this invalid data
        if (len != correctLength(width, height, colorspace, componentbits))
        {
            std::ostringstream ss;
            ss << "wrong buffer size for PDF image of size "
               << width << "x" << height
               << " (" << colorspace << "): " << len;
            form.log(ss.str(), LogType::Warning);

            std::free(buffer);
            return pixels;
        }

        std::unique_ptr<char> stream(new char[len+s.size()]);
        std::memcpy(stream.get(), s.c_str(), s.size());
        std::memcpy(stream.get()+s.size(), buffer, len);
        std::free(buffer);

        pixels = Pixels(IL_PNM, stream.get(), len+s.size(), filename);
    }

    return pixels;
}
コード例 #11
0
void BevelEmbossStyle::operator() (Pixels destPixels, Pixels maskPixels)
{
    jassert (destPixels.isRGB ());
    jassert (maskPixels.getBounds () == destPixels.getBounds ());

    if (!active)
        return;

    // Calculate the distance transform on the mask.
    //
    typedef double T;
    Map2D <T> distMap (maskPixels.getWidth (), maskPixels.getHeight ());
    switch (kind)
    {
    case kindOuterBevel:
#if 1
        DistanceTransform::Meijster::calculateAntiAliased (
            AntiAliased::Output <Map2D <T> > (distMap, size),
            AntiAliased::GetMaskOuter (maskPixels),
            maskPixels.getWidth (),
            maskPixels.getHeight (),
            DistanceTransform::Meijster::EuclideanMetric ());
#else
        DistanceTransform::Meijster::calculate (
            Normal::OutputOuter <Map2D <T> > (distMap, size),
            Normal::GetOuter (maskPixels),
            maskPixels.getWidth (),
            maskPixels.getHeight (),
            DistanceTransform::Meijster::EuclideanMetric ());
#endif
        break;

    case kindInnerBevel:
#if 1
        DistanceTransform::Meijster::calculateAntiAliased (
            AntiAliased::Output <Map2D <T> > (distMap, size),
            AntiAliased::GetMaskInner (maskPixels),
            maskPixels.getWidth (),
            maskPixels.getHeight (),
            DistanceTransform::Meijster::EuclideanMetric ());
#else
        DistanceTransform::Meijster::calculate (
            Normal::OutputInner <Map2D <T> > (distMap, size),
            Normal::GetInner (maskPixels),
            maskPixels.getWidth (),
            maskPixels.getHeight (),
            DistanceTransform::Meijster::EuclideanMetric ());
#endif
        break;

    case kindEmboss:
    case kindPillowEmboss:
    case kindStrokeEmboss:
    default:
        jassertfalse;
        break;
    }

#if 0
    {
        for (int y = 0; y < destPixels.getWidth (); ++y)
        {
            for (int x = 0; x < destPixels.getHeight (); ++x)
            {
                PixelRGB& dest (*((PixelRGB*)destPixels.getPixelPointer (x, y)));

                T t = distMap (x, y) * 255 / size;
                uint8 v = uint8 (t + 0.5);

                dest.getRed () = v;
                dest.getGreen () = v;
                dest.getBlue () = v;
            }
        }
    }
#else
    // Apply a softening to the transform.
    //
#if 0
    if (technique == techniqueChiselSoft)
    {
        if (soften > 0)
        {
            RadialImageConvolutionKernel k (soften + 1);
            k.createGaussianBlur ();
            distImage = k.createConvolvedImage (distImage);
            distPixels = Pixels (distImage);
        }
    }
#endif

    Image hiImage (
        Image::SingleChannel,
        destPixels.getCols (),
        destPixels.getRows (),
        true);

    Image loImage (
        Image::SingleChannel,
        destPixels.getCols (),
        destPixels.getRows (),
        true);

    Pixels hiPixels (hiImage);
    Pixels loPixels (loImage);

    LightingTransform::calculate <T> (
        LightingTransform::PixelShader (hiPixels, loPixels),
        distMap,
        10 - depth,
        lightAngle,
        lightElevation);

    // Apply a softening to the masks.
    //
#if 0
    if (technique == techniqueSmooth)
    {
        if (soften > 0)
        {
            RadialImageConvolutionKernel k (soften + 1);
            k.createGaussianBlur ();

            hiImage = k.createConvolvedImage (hiImage);
            hiPixels = Pixels (hiImage);

            loImage = k.createConvolvedImage (loImage);
            loPixels = Pixels (loImage);

            Pixels::Iterate2 (hiPixels, maskPixels) (BlendProc::Gray::CopyMode <BlendMode::multiply> ());
            Pixels::Iterate2 (loPixels, maskPixels) (BlendProc::Gray::CopyMode <BlendMode::multiply> ());
        }
    }
#endif

    // Render highlights.
    //
    BlendMode::apply (
        hilightMode,
        Pixels::Iterate2 (destPixels, hiPixels),
        BlendProc::RGB::MaskFill (hilightColour, hilightOpacity));

    // Render shadows.
    //
    BlendMode::apply (
        shadowMode,
        Pixels::Iterate2 (destPixels, loPixels),
        BlendProc::RGB::MaskFill (shadowColour, shadowOpacity));
#endif
}