MCPcopy Index your code
hub / github.com/MapServer/MapServer / pam_computeacolorhash

Function pam_computeacolorhash

mapquantization.c:614–658  ·  view source on GitHub ↗
( apixels, cols, rows, maxacolors, acolorsP )

Source from the content-addressed store, hash-verified

612
613
614static acolorhash_table
615pam_computeacolorhash( apixels, cols, rows, maxacolors, acolorsP )
616rgbaPixel** apixels;
617int cols, rows, maxacolors;
618int* acolorsP;
619{
620 acolorhash_table acht;
621 register rgbaPixel* pP;
622 acolorhist_list achl;
623 int col, row, hash;
624
625 acht = pam_allocacolorhash( );
626 *acolorsP = 0;
627
628 /* Go through the entire image, building a hash table of colors. */
629 for ( row = 0; row < rows; ++row )
630 for ( col = 0, pP = apixels[row]; col < cols; ++col, ++pP )
631 {
632 hash = pam_hashapixel( *pP );
633 for ( achl = acht[hash]; achl != (acolorhist_list) 0; achl = achl->next )
634 if ( PAM_EQUAL( achl->ch.acolor, *pP ) )
635 break;
636 if ( achl != (acolorhist_list) 0 )
637 ++(achl->ch.value);
638 else
639 {
640 if ( ++(*acolorsP) > maxacolors )
641 {
642 pam_freeacolorhash( acht );
643 return (acolorhash_table) 0;
644 }
645 achl = (acolorhist_list) malloc( sizeof(struct acolorhist_list_item) );
646 if ( achl == 0 ) {
647 fprintf( stderr, " out of memory computing hash table\n" );
648 exit(7);
649 }
650 achl->ch.acolor = *pP;
651 achl->ch.value = 1;
652 achl->next = acht[hash];
653 acht[hash] = achl;
654 }
655 }
656
657 return acht;
658}
659
660
661

Callers 1

pam_computeacolorhistFunction · 0.85

Calls 2

pam_allocacolorhashFunction · 0.85
pam_freeacolorhashFunction · 0.85

Tested by

no test coverage detected