Esempio n. 1
0
void Image::writeSRGBA8Pixel(byte_t* data, unsigned int width, unsigned int height, unsigned int depth, unsigned int x,
                             unsigned int y, unsigned int z, const Color& color)
{
    data += (width * height * z + width * y + x) * 4;

    data[0] = sRGB::fromLinear(color.r);
    data[1] = sRGB::fromLinear(color.g);
    data[2] = sRGB::fromLinear(color.b);
    data[3] = byte_t(color.a * 255.0f);
}
Esempio n. 2
0
template <> Vector<byte_t> UnicodeString::toUTF8(bool includeNullTerminator) const
{
    auto result = Vector<byte_t>();

    for (auto i = 0U; i < length(); i++)
    {
        auto c = at(i);

        if (c < 0x80)
            result.append(byte_t(c));
        else if (c < 0x800)
        {
            result.append(0xC0 | ((c >> 6) & 0x1F));
            result.append(0x80 | (c & 0x3F));
        }
        else if (c < 0x10000)
Esempio n. 3
0
static byte_t fromLinear(float value)
{
    auto result = 0.0f;

    if (!std::isfinite(value))
        ;
    else if (value > 1.0f)
        result = 1.0f;
    else if (value < 0.0f)
        ;
    else if (value < 0.0031308f)
        result = value * 12.92f;
    else
        result = 1.055f * powf(value, (1.0f / 2.4f)) - 0.055f;

    return byte_t(floorf(255.0f * result + 0.5f));
}
Esempio n. 4
0
static pfs::byte_string __to_hex (const char * orig, size_t count)
{
	pfs::byte_string r;
	pfs::byte_string num;

	for (size_t i = 0; i < count; ++i) {
		num = pfs::byte_string::toString(byte_t(orig[i]), 16);

		if (num.size() < 2) {
			r.append(1, '0');
		}
		r.append(num);

		if (i < count - 1)
			r.append(1, ' ');
	}
	return r;
}
SCERROR Surface::TransparentBlt_(
  Surface* to,
  Surface* from,
  u32_t trans,
  int x, int y ,
  const rect_t* rect)
{
  rect_t r;
  unsigned surfmt = Surface::GET_PIXFORMAT(from->GetFormat());
  fail_if ( surfmt != Surface::GET_PIXFORMAT(to->GetFormat()) );
  if ( !PrepareRect(r,to,from,x,y,rect) ) return SCE_OK;
  const int width = r.right-r.left;
  if ( width == 0 ) return SCE_OK;
  SurfLock lfrom(from); reterr_if ( lfrom.PeekError() );
  SurfLock lto(to);     reterr_if ( lto.PeekError() );
  int src_stride,dst_stride;  // получаем адреса памяти для пикселей
  cbyte_t* src = (cbyte_t*)lfrom->GetMemory(src_stride);
  byte_t* dst  = (byte_t*)lto->GetMemory(dst_stride);
  int depth = 0;
  switch ( surfmt ) {
  case Surface::RGBx32: depth = 4; break;
  case Surface::RGB5x5: depth = 2; break;
  case Surface::PAL:    
  case Surface::ALPHA:  depth = 1; break;
  default: fail_if ("INVALID SURFACE FORMAT");
  }
  dst+=y*dst_stride+x*depth;            //
  src+=r.top*src_stride+r.left*depth;   // поправка на координаты
  switch ( surfmt ) {
  case Surface::RGBx32: 
    CopyTransparentRect_T(r.bottom-r.top,src,src_stride,dst,dst_stride,width,u32_t(trans));
    break;
  case Surface::RGB5x5: 
    CopyTransparentRect_T(r.bottom-r.top,src,src_stride,dst,dst_stride,width,u16_t(trans));
    break;
  case Surface::PAL:    
  case Surface::ALPHA:  
    CopyTransparentRect_T(r.bottom-r.top,src,src_stride,dst,dst_stride,width,byte_t(trans));
    break;
  default: fail_if ("INVALID SURFACE FORMAT");
  }
  return SCE_OK;
}
Esempio n. 6
0
 void Helper::inv_sub_bytes(string& cipher)
 {
   for (number_size_t i = 0; i < BLOCK_BYTE_SIZE; ++i) {
     cipher[i] = InvSBox[byte_t(cipher[i])];
   }
 }
Esempio n. 7
0
 void Helper::sub_word(string& word)
 {
   for (number_size_t i = 0; i < BLOCK_ROWS; ++i) {
     word[i] = SBox[byte_t(word[i])];
   }
 }
Esempio n. 8
0
	/**
	*	@brief	Returns the amount, in bytes, of the device commited memory of lazily-allocated
	*			(VK_MEMORY_PROPERTY_LAZILY_ALLOCATED_BIT) memory.
	*
	*			It is the callers responsibility to ensure that this memory object was allocated with a lazily-allocated
	*			memory type, otherwise the return value is undefined.
	*/
	auto get_allocation_memory_commitment() const {
		std::uint64_t committed_bytes;
		vkGetDeviceMemoryCommitment(device.get(), *this, &committed_bytes);
		return byte_t(committed_bytes);
	}