![]() |
|
![]() |
|
|
Thread Tools | Display Modes |
|
|
#1 |
|
Newbie
Join Date: Jan 2006
Posts: 7
Rep Power: 0
![]() |
outputting to a file to create a image
hey all
ive got my quadtree thing workin (somehow without using pointers properly go figure) hehe. anyways, what im trying to do is this - when it finds a region that say has pixels within it that are the same colour, or it reaches the bottom of the tree and quads. i want to output it straight to a file. the problem with this is - that when i do this, it sticks the RGB values in the order that they have been checked (i know why it does this, it makes sense) is there anyway of outputting them directly to a file where they should be? instead of just one after another? or am thinking in mad mans terms (prolly the later) below is the code i am using, FILE *q is the pointer to the output file void createLeafNode(int StartXAxis,int StartYAxis,int WidthOfQuadrant, int HeightOfQuadrant, quadtreeNode *newNode,quadtreeNode *ptr_root, Pixel Image[], int width, int height,FILE *fp,FILE *q)
{
int x = StartXAxis;//+WidthOfQuadrant)-1;
int y = StartYAxis;//+HeightOfQuadrant)-1;
newNode = new struct quadtreeNode;
newNode->R = Image[x+(y*width)].R;
newNode->G = Image[x+(y*width)].G;
newNode->B = Image[x+(y*width)].B;
newNode->StartWidth = StartXAxis;
newNode->StartHeight = StartYAxis;
newNode->WidthOfRegion = WidthOfQuadrant;
newNode->HeightOfRegion = HeightOfQuadrant;
//create neaf node test
// printf("R: %d : G %d : B %d Coords X:%d,Y:%d Width of quadrant %d Height of quadrant %d\n",Image[x+(y*width)].R, Image[x+(y*width)].G, Image[x+(y*width)].B,x,y,WidthOfQuadrant,HeightOfQuadrant);
outputToFile(StartXAxis,StartYAxis,WidthOfQuadrant,HeightOfQuadrant,newNode,ptr_root,Image,width,height,fp,q);
}
void outputToFile(int StartXAxis, int StartYAxis, int WidthOfQuadrant, int HeightOfQuadrant, quadtreeNode *newNode, quadtreeNode *ptr_root, Pixel Image[], int width,int height,FILE *fp,FILE *q)
{
int x = StartXAxis;
int y = StartYAxis;
for (int a=StartXAxis;a<StartXAxis+WidthOfQuadrant;a++)
{
for (int b=StartYAxis;b<StartYAxis+HeightOfQuadrant;b++)
{
fprintf(q, "%c", newNode->R);
fprintf(q, "%c", newNode->G);
fprintf(q, "%c", newNode->R);
//output to file test
// printf(" R: %d : G %d : B %d \n",Image[x+(y*width)].R, Image[x+(y*width)].G, Image[x+(y*width)].B);
}
}
}any help would be appreciated, its driving me up the wall lol rob |
|
|
|
![]() |
| Bookmarks |
| Currently Active Users Viewing This Thread: 1 (0 members and 1 guests) | |
| Thread Tools | |
| Display Modes | |
|
|