Made the png_loader::get_image() function a little faster.

This commit is contained in:
Davis King 2011-05-27 15:52:37 -04:00
parent 7b6de12578
commit b81db5eb49
1 changed files with 22 additions and 6 deletions

View File

@ -40,17 +40,26 @@ namespace dlib
#endif
t.set_size( height_, width_ );
for ( unsigned n = 0; n < height_;n++ )
if (is_gray())
{
const unsigned char* v = get_row( n );
for ( unsigned m = 0; m < width_;m++ )
for ( unsigned n = 0; n < height_;n++ )
{
if ( is_gray() )
const unsigned char* v = get_row( n );
for ( unsigned m = 0; m < width_;m++ )
{
unsigned char p = v[m];
assign_pixel( t[n][m], p );
}
else if ( is_rgb() )
}
}
else if (is_rgb())
{
for ( unsigned n = 0; n < height_;n++ )
{
const unsigned char* v = get_row( n );
for ( unsigned m = 0; m < width_;m++ )
{
rgb_pixel p;
p.red = v[m*3];
@ -58,7 +67,14 @@ namespace dlib
p.blue = v[m*3+2];
assign_pixel( t[n][m], p );
}
else if ( is_rgba() )
}
}
else if (is_rgba())
{
for ( unsigned n = 0; n < height_;n++ )
{
const unsigned char* v = get_row( n );
for ( unsigned m = 0; m < width_;m++ )
{
rgb_alpha_pixel p;
p.red = v[m*4];