summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorBryson Steck <brysonsteck@protonmail.com>2022-08-28 00:42:25 -0600
committerBryson Steck <brysonsteck@protonmail.com>2022-08-28 00:42:25 -0600
commit86e969f105385484d7e29bac1e5e7fa2182abed8 (patch)
treeeaf623fc2e5a4bd2b86ec79e4fc65f96d2e87683
parent0461cec5fdb4b41d6d9bbd0e16f8572d9204f953 (diff)
downloaduirc-86e969f105385484d7e29bac1e5e7fa2182abed8.tar
uirc-86e969f105385484d7e29bac1e5e7fa2182abed8.tar.gz
uirc-86e969f105385484d7e29bac1e5e7fa2182abed8.tar.bz2
used wrong stbi function this whole time. big performanceHEADmaster
-rw-r--r--uirc.c26
1 files changed, 13 insertions, 13 deletions
diff --git a/uirc.c b/uirc.c
index 7af0ace..1f52977 100644
--- a/uirc.c
+++ b/uirc.c
@@ -46,7 +46,6 @@ bool singular = false;
bool rFlag = false;
int getBcf(int width, int height) {
- int *widthFactors, *heightFactors;
unsigned int bcf;
for (int i = 1; i <= width; i++) {
for (int j = 1; j <= height; j++) {
@@ -66,24 +65,26 @@ bool compare_float(float a, float b) {
int readFile(char *file, bool rFlag, unsigned int req, char* url) {
char *displayfile;
+ int result;
unsigned int width, height, channels, factor;
- unsigned char *img = stbi_load(file, &width, &height, &channels, 0);
+ result = stbi_info(file, &width, &height, &channels);
- if (img == NULL) {
+ if (access(file, F_OK) != 0) {
if (req == 0) {
printf("FAIL\nuirc: request failed (%s), trying local fs instead\n", url);
return 4;
- } else if (access(file, F_OK) != 0) {
+ } else {
printf("uirc: %s: No such file or directory\n", file);
exit(6);
- } else {
- if (access(file, R_OK) != 0) {
- printf("uirc: %s: Permission denied\n", file);
- exit(3);
- } else {
- printf("uirc: %s: Not an image or unsupported image type\n", file);
- exit(10);
- }
+ }
+ } else {
+ if (access(file, R_OK) != 0) {
+ printf("uirc: %s: Permission denied\n", file);
+ exit(3);
+ }
+ if (result != 1) {
+ printf("uirc: %s: Not an image or unsupported image type\n", file);
+ exit(10);
}
}
@@ -91,7 +92,6 @@ int readFile(char *file, bool rFlag, unsigned int req, char* url) {
printf("ok\n");
factor = getBcf(width, height);
- stbi_image_free(img);
double wuneven = ((float) height) / ((float) width);
double huneven = ((float) width) / ((float) height);