Sorry your browser is not supported!

You are using an outdated browser that does not support modern web technologies, in order to use this site please update to a new browser.

Browsers supported include Chrome, FireFox, Safari, Opera, Internet Explorer 10+ or Microsoft Edge.

Dark GDK / Concatenate number onto char*

Author
Message
Plystire
21
Years of Service
User Offline
Joined: 18th Feb 2003
Location: Staring into the digital ether
Posted: 3rd Aug 2009 13:04
I know it's possible... but how is it done?


What I'm trying to do is find an unused file name and the file names have numbers at the end, so i was gonna loop through numbers until I found a file name that didn't exist and could be used.

Example: "Pic7.jpg"


The one and only,


Zuka
16
Years of Service
User Offline
Joined: 21st Apr 2008
Location: They locked me in the insane asylum.
Posted: 3rd Aug 2009 13:06
char buf[256];
sprintf(buf, "Pic%d.jpg", num);

Plystire
21
Years of Service
User Offline
Joined: 18th Feb 2003
Location: Staring into the digital ether
Posted: 3rd Aug 2009 13:17
Huh... when I do it like that, I get a "buffer overrun" debug message when I escape the program.


It did work, though. So, I'm happy about that.


The one and only,


Zuka
16
Years of Service
User Offline
Joined: 21st Apr 2008
Location: They locked me in the insane asylum.
Posted: 3rd Aug 2009 13:34
Buffer overrun? Hmm... maybe



Plystire
21
Years of Service
User Offline
Joined: 18th Feb 2003
Location: Staring into the digital ether
Posted: 3rd Aug 2009 13:49 Edited at: 3rd Aug 2009 13:50
Awesome, that fixed it much better. Thanks a ton, Zuka!

Now my problem is with the saved file.

Here's my screenshot code: (Saves a screenshot)


The resolution (SW and SH) is 1280x1024. The image gets saved as a 2048x1024 image... which is understandable considering it's in a power of 2, but how do I make it save the image in the correct dimensions?


The one and only,


Caleb1994
15
Years of Service
User Offline
Joined: 10th Oct 2008
Location: The Internet you idiot!
Posted: 4th Aug 2009 01:13
The only way i could think is to make a offscreen bitmap the same size as the image you need then copy the bitmap you want to save to that one and save that bitmap,and get a image of that bitmap if you need it.

New Site! Check it out \/
Amnzero
15
Years of Service
User Offline
Joined: 1st Aug 2009
Location:
Posted: 5th Aug 2009 18:39 Edited at: 5th Aug 2009 21:51
#include <string.h>

char string1 = "pic";
int num = 7;

strcat(string1, dbStr(num));
strcat(string1, ".jpg");

[ Amnzero ]

if(enemy == "Troll" runAway();
Amnzero
15
Years of Service
User Offline
Joined: 1st Aug 2009
Location:
Posted: 5th Aug 2009 18:42
dbGetImage(1,0,0,SW,SH, 1);

the extra flag at the end will tell the GDK to not resize the image for texturing when it is loaded.

[ Amnzero ]

Login to post a reply

Server time is: 2024-10-01 08:41:28
Your offset time is: 2024-10-01 08:41:28