I was disappointed when zeldaking never finished his Paint program, so I Decided to make my own!





It's got circle drawing(no ellipse), rectangle drawing, line drawing, pen, floodfill, zooming in(plus button), zooming out(minus), has a grid for larger than 3x, and a color picker(hope I didn't leave anything out). It took me a while to figure out how to make it actually draw, but then I realized that I could draw a sprite to the screen and just edit the sprite data. The problems that I'm having is, opening files(.ppf files stands for Prizm Picture Files, I already have saving working okay), rotating image(I couldn't figure out how, I asked in my topic, but no one helped), resizing properly(resize it so the new image doesn't look corrupted and just adds white pixels in those places), displaying the hex of the color in the color picker(it is only displaying the #?), scaling gets corrupted after the displayed pic gets over 115(or something like that) pixels high or wide, and I think that's it unless I forgot.

Here is the opening code(if you can help, it segfaults the calc at the end of the progress bar):

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;
}


I don't have any code for rotating(90 degree increments), but if you could help, it would be nice.

Here is my resizing code, so if you could help make the output less corrupted:

Code:
void resizeImage(color_t *image, int w1, int h1, int w2, int h2){
    int w, h;
    color_t* holder = image;
    color_t* temp = (color_t*)malloc(((w1*h1)*2)*sizeof(color_t));
    temp = (color_t*)realloc(temp, ((w2*h2)*2)*sizeof(color_t));
    if ( temp != NULL ){
        image = temp;
    } else {
        free(temp);
        return;
    }
    if(w1 < w2){
        w = w1;
    } else {
        w = w2;
    }
    if(h1 < h2){
        h = h1;
    } else {
        h = h2;
    }
    for(int i = 0; i < h; i++){
        for(int j = 0; j < w; j++){
            image[(i*w)+j] = holder[(i*w)+j];
        }
    }
}


Here is the code for changing the RGB values to Hex(based off of my TI-BASIC program):

Code:
char* RGBtoHex(int r, int g, int b, char buffer[7]){
    char val[16] = "0123456789ABCDEF";
    float a = (r/16);
    float c = (g/16);
    float d = (b/16);
    int e = floor(a);
    int f = floor(c);
    int h = floor(d);
    if(e > a)
        e--;
    if(f > d)
        f--;
    if(h > c)
        h--;
    a = a - e;
    c = c - h;
    d = d - f;
    a = a * 16;
    c = c * 16;
    d = d * 16;
    buffer[0] = '#';
    buffer[1] = val[e];
    buffer[2] = val[(int)a];
    buffer[3] = val[f];
    buffer[4] = val[(int)d];
    buffer[5] = val[h];
    buffer[6] = val[(int)c];
    return buffer;
}


And, finally here is my nearest-neighbor scaling routine:

Code:
color_t* Scale(color_t *temp, const color_t* data,int w1,int h1,int w2,int h2) {
    if((w2 <= 0) || (h2 <= 0)){
        return 0;
    } else {
        color_t* milk = (color_t*)realloc(temp, (w2*h2*2)*sizeof(color_t));
        temp = milk;
        int x_ratio = ((w1<<16)/w2)+1;
        int y_ratio = ((h1<<16)/h2)+1;
        int x2, y2;
        for(int i=0;i<h2;i++) {
            for(int j=0;j<w2;j++) {
                x2 = ((j*x_ratio)>>16);
                y2 = ((i*y_ratio)>>16);
                temp[(i*w2)+j] = data[(y2*w1)+x2];
            }
        }
    }
    return temp;
}


I really hope you can help with this. This is pretty much the farthest I've ever made on a Prizm C program from pretty much scratch.

Edit: Also, I don't have an official Icon for this, but if someone could help with that too(you'd get some credit), it would be nice. Also, I don't really like the cursor right now, and I don't know what to change it to. Does anyone have any ideas?

Also, if you help, you get some credit(I'll make an About on the program that lists people who help).
Wow, looks great! is there a download link?

I can try to make an icon for you either today or tomorrow Wink

EDIT:

are these ok?


flyingfisch wrote:
Wow, looks great! is there a download link?

I can try to make an icon for you either today or tomorrow Wink

EDIT:

are these ok?



I am at school, so I can't see the images yet(I'll view them when I get home). I won't put a download link until I get the things I want working.


Edit: Those icons are a little small. Razz Could you make bigger ones, so I can view them better?
How's this?


flyingfisch wrote:
How's this?




Where did you get this from(or did you create it)? I don't think that it would be good for this project. Any other ideas?
Spenceboy98 wrote:
flyingfisch wrote:
How's this?




Where did you get this from(or did you create it)? I don't think that it would be good for this project. Any other ideas?


I made it myself. What ideas do you have for an icon?
flyingfisch wrote:
Spenceboy98 wrote:
flyingfisch wrote:
How's this?




Where did you get this from(or did you create it)? I don't think that it would be good for this project. Any other ideas?


I made it myself. What ideas do you have for an icon?


I like the idea of your icon(painting the prism Razz). I was thinking of a palette thing with a paintbrush on it.
How are these? The icon comes from the elementary icon theme.


flyingfisch wrote:
How are these? The icon comes from the elementary icon theme.




Oooh. I like that(if only you could do that shadow thing behind it like it is in the official programs, but I'll take this for now Smile)! Thank you!

Also, can you make it 92x64 so I can compile it?
There you go Smile


flyingfisch wrote:
There you go Smile




Thanks, I got it installed. Woohoo! Now to fix the other problems!
Those icons are beautiful, Flying; nice job. Spence, this looks great! You got a ton done on this all by yourself. I'm proud of you for making such progress. I definitely will join the other members in encouraging you to make this the best program it can be and of course to finish it.
KermMartian wrote:
Those icons are beautiful, Flying; nice job. Spence, this looks great! You got a ton done on this all by yourself. I'm proud of you for making such progress. I definitely will join the other members in encouraging you to make this the best program it can be and of course to finish it.


Thank you Kerm! Smile Of course, I did get a little help in my topic. Wink
I'm curious, what other features will you be adding?
tifreak8x wrote:
I'm curious, what other features will you be adding?


I should probably add an Eraser. Razz

Here's what I have right now:
-Rectangle
-Circle(not ellipses)
-Line
-Dropper
-Fill
-Color Picker with RGB editing(and hopefully hex code editing, but I need to get the hex displaying fixed first) and some preset colors(the same ones from Paint on Windows)
-Resizing(glitchy)
-Zooming/Scaling(glitchy, needs to be fixed; code is in first post)
-Saving(hopefully editing soon if I can get it to work; code is also in first post)

Planning for eventually:
-Eraser
-Select Tool with Copy, Paste, Crop, etc.

I'll take any suggestions if you have any.
Will there be a text function?
tifreak8x wrote:
Will there be a text function?


I'm not sure. I might attempt it in the future. I didn't really think about that. Razz
Spenceboy98 wrote:

-Color Picker with RGB editing(and hopefully hex code editing, but I need to get the hex displaying fixed first) and some preset colors(the same ones from Paint on Windows)


Could you make the preset colors customizable?
flyingfisch wrote:
Spenceboy98 wrote:

-Color Picker with RGB editing(and hopefully hex code editing, but I need to get the hex displaying fixed first) and some preset colors(the same ones from Paint on Windows)


Could you make the preset colors customizable?


Maybe. I'll try that later(when I finish fixing the problems and publish a demo version). Wink

Edit: I have about enough space for 3 more tools on the main toolbar thing on the side. I will put the more important suggested/planned tools there(eraser, maybe select, and one other thing, maybe text). I will probably need a popout for more tools. Razz
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
  
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
» Goto page 1, 2, 3, 4, 5  Next
» View previous topic :: View next topic  
Page 1 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