tifreak8x wrote:
Could you make the tools section scrollable? Or just have like a next and previous arrow so you can view sections of the tool bar at a time Smile


I'll try eventually, but, again, I'll wait until I have a decent build to publish. Smile

More Screenies:
Me changing width(also changed height, but no screenie for that):

After drawing zoomed in:

Zoomed out:

Saving(I tried to save, but unfortunately the calc crashed. I'll look into it):


For saving, you don't have to add the ".ppf"; it does it for you.
Looks great! Perhaps you could look towards grafx2 for some more feature ideas? http://code.google.com/p/grafx2/
wonderfull
i thought to make sth like that a looong time ago.
but i failed at the menu and the cursor...
Thanks guys!

I keep getting this error trying to resize the image using my scale routine and it keeps giving me this:

Code:
main.c:1584:19: error: incompatible types when assigning to type 'color_t[2048]'
 from type 'color_t *'
main.c:1594:23: error: incompatible types when assigning to type 'color_t[2048]'
 from type 'color_t *'
main.c:1611:19: error: incompatible types when assigning to type 'color_t[2048]'
 from type 'color_t *'


Can anyone help?

I'm doing:

Code:

image = Scale([insert values here]);


Edit: Fixed that^^^

This is what it exports in the .ppf file: http://pastebin.com/Fc0qt7aT
Resizing still isn't working right(using my scale routine and resizing array with realloc). I fixed a small problem with my flood filling routine(it used to reset every time I tried to fill without a boundary/border). Saving is incredibly slow and it gets slower as the image gets larger(the larger the image, the slower it takes).

More screenshots:



As you can see in the second sreenshot, something weird is happening(my guess is that it is from my fill routine because it starts soon after I start using the fill routine). Any ideas?
Can you have it save to main memory? that may be faster...
flyingfisch wrote:
Can you have it save to main memory? that may be faster...


Yes, but is there a file browser for it? Or can I use the same browser I've been using?
hmm... I'm not sure.
The reason that this code:

Code:

void openFile(char *PATH, color_t *data, int width, int height){
    char databuf[5];
    unsigned short buffer[sizeof(PATH)*2];
    Bfile_StrToName_ncpy(buffer, (unsigned char*)PATH, strlen(PATH)+1);
    int hFile = Bfile_OpenFile_OS(buffer, 0);
    for(int i = 0; i < height; i++){
        for(int j = 0; j < width; j++){
            ProgressBar((i*width)+j, width*height);
            Bfile_ReadFile_OS(hFile, databuf, 5, ((i*width+j)+2)*5);
            data[(i*width+j)] = strtol(databuf, NULL, 10);
        }
    }
    Bfile_CloseFile_OS(hFile);
    return;
}

is failing is because of this line is your problem

Code:

    unsigned short buffer[sizeof(PATH)*2];

The first problem is that sizeof(x) does not get the length of the string it gets the size of the pointer. Use strlen instead. Anther issue is that it is failing is because arrays need to be static unless you are using C99. If you are not using C99 then you must use either malloc or alloca() In this case if you are careful I would recommend alloca() as it is automatically freeded after the function returns and I read that the casio prizm has a larger stack compared with heap.
With that in mind you can change

Code:

    unsigned short buffer[sizeof(PATH)*2];

to

Code:

 unsigned short * buffer = alloca(2*(strlen(PATH)+1));

Also I noticed in some of your other code you you did not free memory returned by malloc you MUST do that when you are done with the memory. It is very importan.
Also I think you may need to change

Code:

    Bfile_StrToName_ncpy(buffer, (unsigned char*)PATH, strlen(PATH)+1);

to

Code:

    Bfile_StrToName_ncpy(buffer, (unsigned char*)PATH, strlen(PATH));
Thanks! It opens now!

This is the code for saving files that I'm using:

Code:
void saveFile(char *filename, color_t *data, int width, int height){
    char buffer1[5];
    char widthbuffer[5], heightbuffer[5];
    int size = sizeof(data)+sizeof(width)+sizeof(height);
    char PATH[sizeof("\\\\fls0\\")+strlen1(filename)+sizeof(".ppf")];
    unsigned short pFile[sizeof(PATH)*2];
    strcpy(PATH, "\\\\fls0\\");
    strcat(PATH, filename);
    strcat(PATH, ".ppf");
    Bfile_StrToName_ncpy(pFile, (unsigned char*)PATH, sizeof(PATH));
    Bfile_CreateEntry_OS(pFile, CREATEMODE_FILE, &size);
    int hFile = Bfile_OpenFile_OS(pFile, 2);
    itoa(width, widthbuffer);
    Bfile_WriteFile_OS(hFile, widthbuffer, 5);
    itoa(height, heightbuffer);
    Bfile_WriteFile_OS(hFile, heightbuffer, 5);
    for(int i = 0; i < height; i++){
        for(int j = 0; j < width; j++){
            ProgressBar(i*width+j, width*height);
            itoa(data[(i*width)+j], buffer1);
            /* for(int k = 0; k < 5; k++){
                if(buffer1[k]=='\n')
                    buffer1[k] = '0';
            } */
            Bfile_WriteFile_OS(hFile, buffer1, sizeof(buffer1));
            for(int l = 0; l < 5; l++)
                buffer1[l] = ' ';
        }
    }
    Bfile_CloseFile_OS(hFile);
}


I don't think the slowness can be helped, but maybe it can. :/
The slownees can be helped alot. Your problem is that you are trying to convert binary data into text. That is pointless and illogical. Simply save the raw data without any conversion. Note that this assumes that color_t is a 16bit variable. (2 bytes per pixel if not then the code will need to be changed)

Code:

void saveFile(char *filename, color_t *data, int width, int height){
    int size = (width*height*2)+4;
    char * PATH = alloca (strlen("\\\\fls0\\")+strlen1(filename)+strlen(".ppf")+1);
    strcpy(PATH, "\\\\fls0\\");
    strcat(PATH, filename);
    strcat(PATH, ".ppf");
    unsigned short * pFile = alloca(2*(strlen(PATH)+1));
    Bfile_StrToName_ncpy(pFile, (unsigned char*)PATH, strlen(PATH));
    Bfile_CreateEntry_OS(pFile, CREATEMODE_FILE, &size);
    int hFile = Bfile_OpenFile_OS(pFile, 2);
    Bfile_WriteFile_OS(hFile, &width, 2);
    Bfile_WriteFile_OS(hFile, &height, 2);
    Bfile_WriteFile_OS(hFile, data, width*height*2);
    Bfile_CloseFile_OS(hFile);
}

You will have to change your opening code but now it saves. The first 4 bytes are the width and height and the rest of the bytes are the raw data. You will need to change your loading code to read the raw data. This also saves alot of flash space as plain text takes up more memory than binary/raw data.
Now it doesn't save at all. Razz
Sorry about that I fixed the error in my post above this one which contains faster saving code. Also if you did not notice I removed the progress bar. Redrawing the progress bar so often is what was slowing you down so much if you want to have the progress bar only update it each line. In my code it saves the whole file in one go. Also even if it does not look like it has saved it will most likely be in the flash memory. Here is the new open code for the more efficent format

Code:

void openFile(char *PATH, color_t *data)
{
   //note I removed the need to pass width and height as those are stored in the file 
    char databuf[5]; 
 unsigned short * buffer = alloca(2*(strlen(PATH)+1));
    Bfile_StrToName_ncpy(buffer, (unsigned char*)PATH, strlen(PATH)); 
    int hFile = Bfile_OpenFile_OS(buffer, 0);
   int width,height;
   Bfile_ReadFile_OS(hFile,&width,0);
   Bfile_ReadFile_OS(hFile,&height,2);
    Bfile_ReadFile_OS(hFile, data, width*height*2, 4); 
    Bfile_CloseFile_OS(hFile); 
    return; 
}
Still doesn't save(I checked the memory). :/
Do you mean there is no file. Also I just added new loading code in my previous post after you posted that it is not working.
There is no file. I'll try your open code when I get the save code to work.
What does Bfile_WriteFile_OS() return?It should return whatever width*height*2 ends up being. If not there is an issue. Also see what Bfile_CreateEntry_OS() returns. http://prizm.cemetech.net/index.php/Bfile_CreateEntry_OS claims that it is 0 on success.
I don't know. It should just send to the file.
No that is not what I mean. I mean what value does the function return.
Here is an example of a returning function

Code:

int pow2(int x)
{
 return x*x;
}
void func2(void)
{
 printf("Pow2 returned %d\n",pow2(4));//should display 16
 int val=pow2(5);//25 is now stored in val.
}

See how when the varible type on the very left int and void. If it is void then I do not need to return anything so I could either use return; end the function early or use nothing at all if the function makes it to the end of the function. If the function starts with something other than void then a value must be returned.
I got the saving and opening to work. But when it opens, the pic slides up and out of view. Any ideas?
  
Register to Join the Conversation
Have your own thoughts to add to this or any other topic? Want to ask a question, offer a suggestion, share your own programs and projects, upload a file to the file archives, get help with calculator and computer programming, or simply chat with like-minded coders and tech and calculator enthusiasts via the site-wide AJAX SAX widget? Registration for a free Cemetech account only takes a minute.

» Go to Registration page
Page 2 of 5
» All times are UTC - 5 Hours
 
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum

 

Advertisement