mirror of https://github.com/davisking/dlib.git
Made the png_loader::get_image() function a little faster.
This commit is contained in:
parent
7b6de12578
commit
b81db5eb49
|
@ -40,17 +40,26 @@ namespace dlib
|
|||
#endif
|
||||
|
||||
t.set_size( height_, width_ );
|
||||
|
||||
|
||||
if (is_gray())
|
||||
{
|
||||
for ( unsigned n = 0; n < height_;n++ )
|
||||
{
|
||||
const unsigned char* v = get_row( n );
|
||||
for ( unsigned m = 0; m < width_;m++ )
|
||||
{
|
||||
if ( is_gray() )
|
||||
{
|
||||
unsigned char p = v[m];
|
||||
assign_pixel( t[n][m], p );
|
||||
}
|
||||
}
|
||||
}
|
||||
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())
|
||||
{
|
||||
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];
|
||||
|
|
Loading…
Reference in New Issue