1
1
Fork 0
mirror of https://github.com/QB64Official/qb64.git synced 2024-07-01 09:10:37 +00:00

Merge pull request #112 from QB64Team/IdeImprovements

Ide improvements
This commit is contained in:
Fellippe Heitor 2021-01-21 03:15:39 -03:00 committed by GitHub
commit 2e309e8445
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
6 changed files with 387 additions and 733 deletions

View file

@ -1,46 +1,46 @@
#ifdef QB64_BACKSLASH_FILESYSTEM
#include "src\\EasyBMP.cpp"
#else
#include "src/EasyBMP.cpp"
#include "src\\EasyBMP.cpp"
#else
#include "src/EasyBMP.cpp"
#endif
uint8 *image_decode_bmp(uint8 *content,int32 bytes,int32 *result,int32 *x,int32 *y){
//Result:bit 1=Success,bit 2=32bit[BGRA]
*result=0;
BMP bm;
if(!bm.ReadFromMemory((char*)content, bytes)){
return NULL;
}
int32 h,w;
h=bm.TellHeight();
w=bm.TellWidth();
uint8 *out;
out=(uint8*)malloc(h*w*4);
uint8* o;
int32 x2,y2;
o=out;
for (y2=0;y2<h;y2++){
for (x2=0;x2<w;x2++){
*o=bm(x2,y2)->Blue; o++;
*o=bm(x2,y2)->Green; o++;
*o=bm(x2,y2)->Red; o++;
*o=255; o++;
}
}
*result=1+2;
*x=w;
*y=h;
return out;
//Result:bit 1=Success,bit 2=32bit[BGRA]
*result=0;
BMP bm;
if(!bm.ReadFromMemory((char*)content, bytes)){
return NULL;
}
int32 h,w;
h=bm.TellHeight();
w=bm.TellWidth();
uint8 *out;
out=(uint8*)malloc(h*w*4);
uint8* o;
int32 x2,y2;
o=out;
for (y2=0;y2<h;y2++){
for (x2=0;x2<w;x2++){
*o=bm(x2,y2)->Blue; o++;
*o=bm(x2,y2)->Green; o++;
*o=bm(x2,y2)->Red; o++;
*o=255; o++;
}
}
*result=1+2;
*x=w;
*y=h;
return out;
}

View file

@ -1,110 +1,110 @@
extern uint32 matchcol(int32 r,int32 g,int32 b);
#ifndef DEPENDENCY_IMAGE_CODEC
//Stub(s):
int32 func__loadimage(qbs *f,int32 bpp,int32 passed);
#else
#ifdef QB64_BACKSLASH_FILESYSTEM
#include "decode\\jpg\\src.c"
#include "decode\\png\\src.c"
#include "decode\\bmp\\src.c"
#include "decode\\other\\src.c" //PNG, TGA, BMP, PSD, GIF, HDR, PIC, PNM(PPM/PGM)
#else
#include "decode/jpg/src.c"
#include "decode/png/src.c"
#include "decode/bmp/src.c"
#include "decode/other/src.c" //PNG, TGA, BMP, PSD, GIF, HDR, PIC, PNM(PPM/PGM)
#endif
int32 func__loadimage(qbs *f,int32 bpp,int32 passed){
if (new_error) return 0;
static int32 isHardware;
isHardware=0; if (bpp==33){bpp=32; isHardware=1;}
//validate bpp
if (passed){
if ((bpp!=32)&&(bpp!=256)){error(5); return 0;}
}else{
if (write_page->text){error(5); return 0;}
bpp=-1;
}
if (!f->len) return -1; //return invalid handle if null length string
if (bpp==256) return -1; //return invalid handle if 256-color mode requested (not valid in this version)
//load the file
int32 fh,result = 0;
int64 lof;
fh=gfs_open(f,1,0,0);
if (fh<0) return -1;
lof=gfs_lof(fh);
static uint8* content;
content=(uint8*)malloc(lof); if (!content){gfs_close(fh); return -1;}
result=gfs_read(fh,-1,content,lof);
gfs_close(fh);
if (result<0){free(content); return -1;}
//Identify format:
static int32 format;
format=0;
//'.png'
if (lof>=8){
if ((content[0]==0x89)&&(content[1]==0x50)&&(content[2]==0x4E)&&(content[3]==0x47)&&
(content[4]==0x0D)&&(content[5]==0x0A)&&(content[6]==0x1A)&&(content[7]==0x0A))
{format=2; goto got_format;}//PNG
}//8
//'.bmp'
if (lof>=6){
if ((content[0]==0x42)&&(content[1]==0x4D)){
if ( (*((int32*)(&content[2]))) == lof ){//length of file
format=3; goto got_format;
}
}//BMP
}//6
//'.jpg' The first two bytes of every JPEG stream are the Start Of Image (SOI) marker values FFh D8h
if (lof>=2){
if ((content[0]==0xFF)&&(content[1]==0xD8)){format=1; goto got_format;}//JP[E]G
}//2
got_format:
static uint8 *pixels;
static int32 x,y;
if (format==1) pixels=image_decode_jpg(content,lof,&result,&x,&y);
if (format==2) pixels=image_decode_png(content,lof,&result,&x,&y);
if (format==3) pixels=image_decode_bmp(content,lof,&result,&x,&y);
if (!(result & 1)) {
pixels=image_decode_other(content,lof,&result,&x,&y);
}
free(content);
if (!(result&1)) return -1;
//...
static int32 i;
static int32 prevDest;
static uint16 scanX, scanY;
static uint8 red, green, blue;
i=func__newimage(x,y,32,1);
if (i==-1){free(pixels); return -1;}
memcpy(img[-i].offset,pixels,x*y*4);
free(pixels);
if (isHardware){
static int32 iHardware;
iHardware=func__copyimage(i,33,1);
sub__freeimage(i,1);
i=iHardware;
}
return i;
}
//Stub(s):
int32 func__loadimage(qbs *f,int32 bpp,int32 passed);
#else
#ifdef QB64_BACKSLASH_FILESYSTEM
#include "decode\\jpg\\src.c"
#include "decode\\png\\src.c"
#include "decode\\bmp\\src.c"
#include "decode\\other\\src.c" //PNG, TGA, BMP, PSD, GIF, HDR, PIC, PNM(PPM/PGM)
#else
#include "decode/jpg/src.c"
#include "decode/png/src.c"
#include "decode/bmp/src.c"
#include "decode/other/src.c" //PNG, TGA, BMP, PSD, GIF, HDR, PIC, PNM(PPM/PGM)
#endif
int32 func__loadimage(qbs *f,int32 bpp,int32 passed){
if (new_error) return 0;
static int32 isHardware;
isHardware=0; if (bpp==33){bpp=32; isHardware=1;}
//validate bpp
if (passed){
if ((bpp!=32)&&(bpp!=256)){error(5); return 0;}
}else{
if (write_page->text){error(5); return 0;}
bpp=-1;
}
if (!f->len) return -1; //return invalid handle if null length string
if (bpp==256) return -1; //return invalid handle if 256-color mode requested (not valid in this version)
//load the file
int32 fh,result = 0;
int64 lof;
fh=gfs_open(f,1,0,0);
if (fh<0) return -1;
lof=gfs_lof(fh);
static uint8* content;
content=(uint8*)malloc(lof); if (!content){gfs_close(fh); return -1;}
result=gfs_read(fh,-1,content,lof);
gfs_close(fh);
if (result<0){free(content); return -1;}
//Identify format:
static int32 format;
format=0;
//'.png'
if (lof>=8){
if ((content[0]==0x89)&&(content[1]==0x50)&&(content[2]==0x4E)&&(content[3]==0x47)&&
(content[4]==0x0D)&&(content[5]==0x0A)&&(content[6]==0x1A)&&(content[7]==0x0A))
{format=2; goto got_format;}//PNG
}//8
//'.bmp'
if (lof>=6){
if ((content[0]==0x42)&&(content[1]==0x4D)){
if ( (*((int32*)(&content[2]))) == lof ){//length of file
format=3; goto got_format;
}
}//BMP
}//6
//'.jpg' The first two bytes of every JPEG stream are the Start Of Image (SOI) marker values FFh D8h
if (lof>=2){
if ((content[0]==0xFF)&&(content[1]==0xD8)){format=1; goto got_format;}//JP[E]G
}//2
got_format:
static uint8 *pixels;
static int32 x,y;
if (format==1) pixels=image_decode_jpg(content,lof,&result,&x,&y);
if (format==2) pixels=image_decode_png(content,lof,&result,&x,&y);
if (format==3) pixels=image_decode_bmp(content,lof,&result,&x,&y);
if (!(result & 1)) {
pixels=image_decode_other(content,lof,&result,&x,&y);
}
free(content);
if (!(result&1)) return -1;
//...
static int32 i;
static int32 prevDest;
static uint16 scanX, scanY;
static uint8 red, green, blue;
i=func__newimage(x,y,32,1);
if (i==-1){free(pixels); return -1;}
memcpy(img[-i].offset,pixels,x*y*4);
free(pixels);
if (isHardware){
static int32 iHardware;
iHardware=func__copyimage(i,33,1);
sub__freeimage(i,1);
i=iHardware;
}
return i;
}
#endif

View file

@ -29,27 +29,19 @@ IF LoadedIDESettings = 0 THEN
GOSUB CheckConfigFileExists 'make certain the config file exists and if not, create one
IF INSTR(_OS$, "WIN") THEN
result = ReadConfigSetting("AllowIndependentSettings", value$)
IF result THEN
IF value$ = "TRUE" OR ABS(VAL(value$)) = 1 THEN 'We default to false and only use one set of IDE settings, no matter how many windows we open up
IDE_Index$ = "(" + LTRIM$(RTRIM$(STR$(tempfolderindex))) + ")"
ConfigFile$ = "internal/config" + IDE_Index$ + ".txt"
ConfigBak$ = "internal/config" + IDE_Index$ + ".bak"
GOSUB CheckConfigFileExists
ELSE
WriteConfigSetting "'[GENERAL SETTINGS]", "AllowIndependentSettings", "FALSE"
IDE_Index$ = ""
END IF
result = ReadConfigSetting("AllowIndependentSettings", value$)
IF result THEN
IF value$ = "TRUE" OR ABS(VAL(value$)) = 1 THEN 'We default to false and only use one set of IDE settings, no matter how many windows we open up
IDE_Index$ = "(" + LTRIM$(RTRIM$(STR$(tempfolderindex))) + ")"
ConfigFile$ = "internal/config" + IDE_Index$ + ".txt"
ConfigBak$ = "internal/config" + IDE_Index$ + ".bak"
GOSUB CheckConfigFileExists
ELSE
WriteConfigSetting "'[GENERAL SETTINGS]", "AllowIndependentSettings", "FALSE"
IDE_Index$ = ""
END IF
ELSE
'Linux doesn't offer multiple temp folders and thus can not work properly with independent settings
'This option is not included on Linux, and if manually inserted will simply be ignored.
WriteConfigSetting "'[GENERAL SETTINGS]", "AllowIndependentSettings", "FALSE"
IDE_Index$ = ""
END IF

View file

@ -135,7 +135,6 @@ DIM SHARED ideroot AS STRING
DIM SHARED idetxt(1000) AS STRING
DIM SHARED idetxtlast AS INTEGER
DIM SHARED idehl
DIM SHARED idealtcode(255) AS INTEGER
DIM SHARED ideprogname AS STRING
DIM SHARED idepath AS STRING
DIM SHARED idefindtext AS STRING

File diff suppressed because it is too large Load diff

View file

@ -1048,16 +1048,6 @@ IF C = 9 THEN 'run
GOTO sendcommand
END IF
'hack! (a new message should be sent to the IDE stating C++ compilation was successful)
COLOR 7, 1: LOCATE idewy - 3, 2: PRINT SPACE$(idewx - 2);: LOCATE idewy - 2, 2: PRINT SPACE$(idewx - 2);: LOCATE idewy - 1, 2: PRINT SPACE$(idewx - 2); 'clear status window
IF idemode THEN
'Darken fg/bg colors
dummy = DarkenFGBG(1)
COLOR 15
END IF
LOCATE idewy - 3, 2: PRINT "Starting program...";
PCOPY 3, 0
'execute program
IF iderunmode = 1 THEN