hi!!
this is the part of a code on which i m working and image is read in .pcx format.if i already define rows and coloums then it reads the image but if i use this command (fscanf(f,"%d %d",&cols,&rows);)then it just stuck up.so plzz help me out wid dis code!!
/*
** Initialize the color octree
*/
octree = CreateOctNode(0);
/*
** Loop through the image and store each unique color.
*/
for (i = 0L; i < (ulong)rows*(ulong)cols; i++) {
/*
** Show progress...
*/
if ((i % (ulong)cols) == 0L) printf("%ld\r",i/cols);
/*
** Insert this color into the octree
*/
InsertTree(&octree, &color, 0);
/*
** If there are too many colors in the tree as a result of this
** insert, reduce the octree
*/
while (TotalLeafNodes() > npal) {
ReduceTree();
}
}
/*
** Make a pass through the completed octree to average down the
** rgb components. When done, 'n' contains the actual number of
** colors in the palette table.
*/
n = 0;
MakePaletteTable(octree, palette, &n);
/*
** How long did it take?
*/
time(&tend);
printf("Processed %ld pixels per second\ninto %d quantized colors\n",
((long)rows*(long)cols)/(tend-tstart), n);
j = 0;
while (j != 3) {
printf("Output to (1)monitor or (2).PCX file or (3) quit: ");
scanf("%s",title);
j = atoi(title);
if (j == 2) {
fseek(f,image_start,0);
SaveAsPCX(f, octree, cols, rows, nrgbr, nrgbg, nrgbb, npal, palette);
}
}
}