Skip to content

Instantly share code, notes, and snippets.

@BSVino
Created September 10, 2014 01:11
Show Gist options
  • Select an option

  • Save BSVino/359cc22df7746b540ee3 to your computer and use it in GitHub Desktop.

Select an option

Save BSVino/359cc22df7746b540ee3 to your computer and use it in GitHub Desktop.
#if 1
#if 0
if (stbir_info->flags&STBIR_FLAG_ALPHA_USES_COLORSPACE)
{
for (; x < max_x; x++)
{
int decode_pixel_index = x * channels;
int input_pixel_index = stbir__edge_wrap(edge_horizontal, x, input_w) * channels;
for (c = 0; c < channels; c++)
decode_buffer[decode_pixel_index + c] = stbir__srgb_uchar_to_linear_float[((const unsigned char*)input_data)[input_pixel_index + c]];
}
}
else
{
int color_channels[STBIR_MAX_CHANNELS] = { 0 };
int current = 0;
for (c = 0; c < channels - 1; c++)
{
if (c == alpha_channel)
continue;
color_channels[current++] = c;
}
for (; x < max_x; x++)
{
int decode_pixel_index = x * channels;
int input_pixel_index = stbir__edge_wrap(edge_horizontal, x, input_w) * channels;
for (c = 0; c < channels - 1; c++)
{
int real_c = color_channels[c];
decode_buffer[decode_pixel_index + real_c] = stbir__srgb_uchar_to_linear_float[((const unsigned char*)input_data)[input_pixel_index + real_c]];
}
decode_buffer[decode_pixel_index + alpha_channel] = ((float)((const unsigned char*)input_data)[input_pixel_index + alpha_channel]) / 255;
}
}
break;
#else
#if 0
{int special_alpha = !(stbir_info->flags&STBIR_FLAG_ALPHA_USES_COLORSPACE);
for (; x < max_x; x++)
{
int decode_pixel_index = x * channels;
int input_pixel_index = stbir__edge_wrap(edge_horizontal, x, input_w) * channels;
for (c = 0; c < channels; c++)
{
if (c == alpha_channel && special_alpha)
decode_buffer[decode_pixel_index + alpha_channel] = ((float)((const unsigned char*)input_data)[input_pixel_index + alpha_channel]) / 255;
else
decode_buffer[decode_pixel_index + c] = stbir__srgb_uchar_to_linear_float[((const unsigned char*)input_data)[input_pixel_index + c]];
}
}}
break;
#else
#if 1
if (!(stbir_info->flags&STBIR_FLAG_ALPHA_USES_COLORSPACE))
{
for (; x < max_x; x++)
{
int decode_pixel_index = x * channels;
int input_pixel_index = stbir__edge_wrap(edge_horizontal, x, input_w) * channels;
for (c = 0; c < channels; c++)
decode_buffer[decode_pixel_index + c] = stbir__srgb_uchar_to_linear_float[((const unsigned char*)input_data)[input_pixel_index + c]];
decode_buffer[decode_pixel_index + alpha_channel] = ((float)((const unsigned char*)input_data)[input_pixel_index + alpha_channel]) / 255;
}
}
else
{
for (; x < max_x; x++)
{
int decode_pixel_index = x * channels;
int input_pixel_index = stbir__edge_wrap(edge_horizontal, x, input_w) * channels;
for (c = 0; c < channels; c++)
decode_buffer[decode_pixel_index + c] = stbir__srgb_uchar_to_linear_float[((const unsigned char*)input_data)[input_pixel_index + c]];
}
}
break;
#else
for (c = 0; c < channels; c++)
{
if (c == alpha_channel)
continue;
for (; x < max_x; x++)
{
int decode_pixel_index = x * channels;
int input_pixel_index = stbir__edge_wrap(edge_horizontal, x, input_w) * channels;
decode_buffer[decode_pixel_index + c] = stbir__srgb_uchar_to_linear_float[((const unsigned char*)input_data)[input_pixel_index + c]];
}
}
if (!(stbir_info->flags&STBIR_FLAG_ALPHA_USES_COLORSPACE))
{
int x = -stbir__get_filter_pixel_margin_horizontal(stbir_info);
for (; x < max_x; x++)
{
int decode_pixel_index = x * channels;
int input_pixel_index = stbir__edge_wrap(edge_horizontal, x, input_w) * channels;
decode_buffer[decode_pixel_index + alpha_channel] = ((float)((const unsigned char*)input_data)[input_pixel_index + alpha_channel]) / 255;
}
}
break;
#endif
#endif
#endif
#else
for (; x < max_x; x++)
{
int decode_pixel_index = x * channels;
int input_pixel_index = stbir__edge_wrap(edge_horizontal, x, input_w) * channels;
for (c = 0; c < channels; c++)
decode_buffer[decode_pixel_index + c] = stbir__srgb_uchar_to_linear_float[((const unsigned char*)input_data)[input_pixel_index + c]];
if (!(stbir_info->flags&STBIR_FLAG_ALPHA_USES_COLORSPACE))
decode_buffer[decode_pixel_index + alpha_channel] = ((float)((const unsigned char*)input_data)[input_pixel_index + alpha_channel]) / 255;
}
break;
#endif
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment