removed stupid and non working constructor, a little clean up
git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@14086 a95241bf-73f2-0310-859d-f6bbb57e9c96
This commit is contained in:
@@ -32,10 +32,6 @@ SFHash::SFHash(int size) {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
SFHash::SFHash() {
|
|
||||||
SFHash(4096);
|
|
||||||
}
|
|
||||||
|
|
||||||
void SFHash::AddItem(HashItem *item) {
|
void SFHash::AddItem(HashItem *item) {
|
||||||
item->next = NULL;
|
item->next = NULL;
|
||||||
int pos = item->key % size;
|
int pos = item->key % size;
|
||||||
|
|||||||
@@ -26,8 +26,7 @@ class HashItem {
|
|||||||
|
|
||||||
class SFHash {
|
class SFHash {
|
||||||
public:
|
public:
|
||||||
SFHash();
|
SFHash(int size = 4096);
|
||||||
SFHash(int size);
|
|
||||||
~SFHash();
|
~SFHash();
|
||||||
|
|
||||||
void AddItem(HashItem *item);
|
void AddItem(HashItem *item);
|
||||||
|
|||||||
@@ -201,10 +201,10 @@ SavePalette::SavePalette(BBitmap *bitmap) {
|
|||||||
fatalerror = false;
|
fatalerror = false;
|
||||||
mode = OPTIMAL_PALETTE;
|
mode = OPTIMAL_PALETTE;
|
||||||
|
|
||||||
SFHash *hash = new SFHash(1 << 16);
|
SFHash hash(1 << 16);
|
||||||
if (hash == NULL || hash->fatalerror) {
|
if (hash.fatalerror) {
|
||||||
if (debug) printf("Out of memory in SavePalette(BBitmap *)\n");
|
if (debug)
|
||||||
if (hash != NULL) delete hash;
|
printf("Out of memory in SavePalette(BBitmap *)\n");
|
||||||
fatalerror = true;
|
fatalerror = true;
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
@@ -217,7 +217,6 @@ SavePalette::SavePalette(BBitmap *bitmap) {
|
|||||||
printf("%d %d %d %d or 0x%x\n", (cs & 0xff000000) >> 24, (cs & 0xff0000) >> 16,
|
printf("%d %d %d %d or 0x%x\n", (cs & 0xff000000) >> 24, (cs & 0xff0000) >> 16,
|
||||||
(cs & 0xff00) >> 8, cs & 0xff, cs);
|
(cs & 0xff00) >> 8, cs & 0xff, cs);
|
||||||
}
|
}
|
||||||
delete hash;
|
|
||||||
fatalerror = true;
|
fatalerror = true;
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
@@ -241,23 +240,22 @@ SavePalette::SavePalette(BBitmap *bitmap) {
|
|||||||
bits += 4;
|
bits += 4;
|
||||||
|
|
||||||
unsigned int key = (r << 16) + (g << 8) + b;
|
unsigned int key = (r << 16) + (g << 8) + b;
|
||||||
ColorItem *ci = (ColorItem *)hash->GetItem(key);
|
ColorItem *ci = (ColorItem *)hash.GetItem(key);
|
||||||
if (ci == NULL) {
|
if (ci == NULL) {
|
||||||
ci = new ColorItem(key, 1);
|
ci = new ColorItem(key, 1);
|
||||||
if (ci == NULL) {
|
if (ci == NULL) {
|
||||||
if (debug) printf("Out of memory in SavePalette(BBitmap *)\n");
|
if (debug) printf("Out of memory in SavePalette(BBitmap *)\n");
|
||||||
delete hash;
|
|
||||||
fatalerror = true;
|
fatalerror = true;
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
hash->AddItem((HashItem *)ci);
|
hash.AddItem((HashItem *)ci);
|
||||||
} else {
|
} else {
|
||||||
ci->count++;
|
ci->count++;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
int unique_colors = hash->CountItems();
|
int unique_colors = hash.CountItems();
|
||||||
size_in_bits = 1;
|
size_in_bits = 1;
|
||||||
while (((1 << size_in_bits) < unique_colors) && (size_in_bits < 8)) size_in_bits++;
|
while (((1 << size_in_bits) < unique_colors) && (size_in_bits < 8)) size_in_bits++;
|
||||||
size = 1 << size_in_bits;
|
size = 1 << size_in_bits;
|
||||||
@@ -265,7 +263,6 @@ SavePalette::SavePalette(BBitmap *bitmap) {
|
|||||||
ColorItem **topcolors = (ColorItem **)malloc(size * 4);
|
ColorItem **topcolors = (ColorItem **)malloc(size * 4);
|
||||||
if (topcolors == NULL) {
|
if (topcolors == NULL) {
|
||||||
if (debug) printf("Out of memory in SavePalette(BBitmap *)\n");
|
if (debug) printf("Out of memory in SavePalette(BBitmap *)\n");
|
||||||
delete hash;
|
|
||||||
fatalerror = true;
|
fatalerror = true;
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
@@ -273,7 +270,7 @@ SavePalette::SavePalette(BBitmap *bitmap) {
|
|||||||
for (int x = 0; x < size; x++) topcolors[x] = dummy;
|
for (int x = 0; x < size; x++) topcolors[x] = dummy;
|
||||||
|
|
||||||
for (int x = 0; x < unique_colors; x++) {
|
for (int x = 0; x < unique_colors; x++) {
|
||||||
ColorItem *ci = (ColorItem *)hash->NextItem();
|
ColorItem *ci = (ColorItem *)hash.NextItem();
|
||||||
for (int y = 0; y < size; y++) {
|
for (int y = 0; y < size; y++) {
|
||||||
if (ci->count > topcolors[y]->count) {
|
if (ci->count > topcolors[y]->count) {
|
||||||
for (int z = size - 1; z > y; z--) {
|
for (int z = size - 1; z > y; z--) {
|
||||||
@@ -294,7 +291,6 @@ SavePalette::SavePalette(BBitmap *bitmap) {
|
|||||||
|
|
||||||
delete dummy;
|
delete dummy;
|
||||||
free(topcolors);
|
free(topcolors);
|
||||||
delete hash;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Standard mapping services once a palette is loaded */
|
/* Standard mapping services once a palette is loaded */
|
||||||
|
|||||||
Reference in New Issue
Block a user