Programming Forums
User Name Password Register
 

RSS Feed
FORUM INDEX | TODAY'S POSTS | UNANSWERED THREADS | ADVANCED SEARCH

Reply
 
Thread Tools Display Modes
Old Jan 16th, 2006, 2:00 PM   #1
funkymp
Newbie
 
Join Date: Jan 2006
Posts: 7
Rep Power: 0 funkymp is on a distinguished road
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
funkymp is offline   Reply With Quote
Reply

Bookmarks

« Previous Thread in Forum | Next Thread in Forum »

Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
 
Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Forum Jump




DaniWeb IT Discussion Community
All times are GMT -5. The time now is 1:33 AM.

Powered by vBulletin® Version 3.7.0, Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.
Copyright ©2007 DaniWeb® LLC