FreeBasic IDE-poseidonFB(Update 2024.03.03)

User projects written in or related to FreeBASIC.
Post Reply
Kuan Hsu
Posts: 586
Joined: Sep 16, 2007 15:12
Location: Taiwan

Re: FreeBasic IDE-poseidonFB(Update 2021.09.21)

Post by Kuan Hsu »

aurelVZAB wrote:so ..problem is in iUP
why not use default file load from windows api?
I'm not sure the problem is IUP, my file loader is pure D code with TANGO library.....
I google and get some things about BEX and DEP, but I don't want to switch off the DEP to test.
I make a FileLoader.dll using old poseidon( D IDE ) code to load the files, later I'll commit the .rev470, If remove the FileLoader.dll, poseidonFB will use modified built-in loader.

The FileLoader.dll is Windows only.

If there are any issues / problems, please tell me, thanks~~
Kuan Hsu
Posts: 586
Joined: Sep 16, 2007 15:12
Location: Taiwan

Re: FreeBasic IDE-poseidonFB(Update 2021.09.21)

Post by Kuan Hsu »

MrSwiss wrote:
aurelVZAB wrote:so ..problem is in iUP, why not use default file load from windows api?
Maybe because IUP is cross platform ?? (WIN/LIN and, probably more)
IUP is for cross platform, the file loader is using D language standard library( also cross platform )
The truth is I'm afraid of Windows API.......

2021.09.24:
The FileLoader.dll is full buggy, load one file seem to OK, but load multifiles are DEP / APPCRASH error, I create another FileLoader.dll using D 2.0971, it seem to solve but I need decode UTF-16BE( BOM / without BOM ) by my hand, so I use iconv library to do a new test, the dll with pure C code to test if the problems are about D compiler or not?
Kuan Hsu
Posts: 586
Joined: Sep 16, 2007 15:12
Location: Taiwan

Re: FreeBasic IDE-poseidonFB(Update 2021.10.05)

Post by Kuan Hsu »

Repacked VANYA's updated CHMVIEW into new rev477.AppImage
jepalza
Posts: 149
Joined: Feb 24, 2010 10:08
Location: Spain (Bilbao)

Re: FreeBasic IDE-poseidonFB(Update 2021.10.05)

Post by jepalza »

Updated "Spanish.lng" to 0.477, Changed name to "Espanol.lng" (it's better this)
Get it from my DRIVE:
https://drive.google.com/file/d/1QFXOtC ... sp=sharing

In "English.lng" you has forgot "customtool" line "10 to 12"

Code: Select all

		setcustomtool=Set Custom Tools...
			customtool1=Custom Tool(1)
			customtool2=Custom Tool(2)
			customtool3=Custom Tool(3)
			customtool4=Custom Tool(4)
			customtool5=Custom Tool(5)
			customtool6=Custom Tool(6)
			customtool7=Custom Tool(7)
			customtool8=Custom Tool(8)
			customtool9=Custom Tool(9)
			customtool10=Custom Tool(10)
			customtool11=Custom Tool(11)
			customtool12=Custom Tool(12)
and one line for "debbuger x64":

Code: Select all

		compiler=Compiler
			compilerpath=Compiler Path
			debugpath=Debugger Path
			terminalpath=Terminal Path
			x64path=x64 Compiler Path
			debugx64path=x64 Debugger Path
miilvyxg
Posts: 193
Joined: Dec 07, 2021 6:51

Re: FreeBasic IDE-poseidonFB(Update 2021.10.05)

Post by miilvyxg »

Just downloaded and try on Windows. Code completion simply doesn't work. What did I do wrong?
Kuan Hsu
Posts: 586
Joined: Sep 16, 2007 15:12
Location: Taiwan

Re: FreeBasic IDE-poseidonFB(Update 2021.10.05)

Post by Kuan Hsu »

jepalza wrote:Updated "Spanish.lng" to 0.477, Changed name to "Espanol.lng" (it's better this)
Get it from my DRIVE:
https://drive.google.com/file/d/1QFXOtC ... sp=sharing

In "English.lng" you has forgot "customtool" line "10 to 12"

Code: Select all

		setcustomtool=Set Custom Tools...
			customtool1=Custom Tool(1)
			customtool2=Custom Tool(2)
			customtool3=Custom Tool(3)
			customtool4=Custom Tool(4)
			customtool5=Custom Tool(5)
			customtool6=Custom Tool(6)
			customtool7=Custom Tool(7)
			customtool8=Custom Tool(8)
			customtool9=Custom Tool(9)
			customtool10=Custom Tool(10)
			customtool11=Custom Tool(11)
			customtool12=Custom Tool(12)
and one line for "debbuger x64":

Code: Select all

		compiler=Compiler
			compilerpath=Compiler Path
			debugpath=Debugger Path
			terminalpath=Terminal Path
			x64path=x64 Compiler Path
			debugx64path=x64 Debugger Path
Thanks, I'll update at new rev.
Kuan Hsu
Posts: 586
Joined: Sep 16, 2007 15:12
Location: Taiwan

Re: FreeBasic IDE-poseidonFB(Update 2021.10.05)

Post by Kuan Hsu »

miilvyxg wrote:Just downloaded and try on Windows. Code completion simply doesn't work. What did I do wrong?
The default Enable Parser / Enable Keyword Autocomplete / Enable Include Autocomplete are ON
Please set the compiler path first, and try:
(1)Open a new document
(2)Key in:

Code: Select all

#in
the keyword complete shoulde be work.

Image
(3)Key in:

Code: Select all

"
after #include (with a space), the include complete list should be work, in this example, I choose crt.bi

Image
(4)I want to use fread function, Key in:

Code: Select all

fre
the code complete list should be work.
Image
miilvyxg
Posts: 193
Joined: Dec 07, 2021 6:51

Re: FreeBasic IDE-poseidonFB(Update 2021.10.05)

Post by miilvyxg »

So your IDE actually parse the headers but not simply provide completion via tags file/keywords file like other IDEs? VANYA's IUP_FB_EDITOR offers code completion without needing any installed compiler. Of course it's only complete keywords. It seems yours is more powerful and advanced (theoretically, not tested).
Kuan Hsu
Posts: 586
Joined: Sep 16, 2007 15:12
Location: Taiwan

Re: FreeBasic IDE-poseidonFB(Update 2021.10.05)

Post by Kuan Hsu »

miilvyxg wrote:So your IDE actually parse the headers but not simply provide completion via tags file/keywords file like other IDEs? VANYA's IUP_FB_EDITOR offers code completion without needing any installed compiler. Of course it's only complete keywords. It seems yours is more powerful and advanced (theoretically, not tested).
Yes, the parser will parse the source code and the include headers without tags. ( even default functions is base FB_BuiltinFunctions.bi, poseidonFB will parse it while loading )
miilvyxg
Posts: 193
Joined: Dec 07, 2021 6:51

Re: FreeBasic IDE-poseidonFB(Update 2021.10.05)

Post by miilvyxg »

Kuan Hsu wrote:
miilvyxg wrote:So your IDE actually parse the headers but not simply provide completion via tags file/keywords file like other IDEs? VANYA's IUP_FB_EDITOR offers code completion without needing any installed compiler. Of course it's only complete keywords. It seems yours is more powerful and advanced (theoretically, not tested).
Yes, the parser will parse the source code and the include headers without tags. ( even default functions is base FB_BuiltinFunctions.bi, poseidonFB will parse it while loading )
Yours is really an IDE, others are just text editors. They are a bit better than Geany at best.
AWPStar
Posts: 47
Joined: May 03, 2009 21:47

Re: FreeBasic IDE-poseidonFB(Update 2021.10.05)

Post by AWPStar »

my report(477):

-scintillaFore color is alway disables and black. I can fix it by editing it in editorSettings.ini, but just until next restart.
-Got new crash(just once) while using mouse wheel.
-I still experience crash when open new file.
-Saving Color template makes all colors black.
-CTRL+LMB routing doesn't work with "Multi selection" option. (because of CTRL?)
Kuan Hsu
Posts: 586
Joined: Sep 16, 2007 15:12
Location: Taiwan

Re: FreeBasic IDE-poseidonFB(Update 2021.10.05)

Post by Kuan Hsu »

AWPStar wrote:my report(477):

-scintillaFore color is alway disables and black. I can fix it by editing it in editorSettings.ini, but just until next restart.
-Got new crash(just once) while using mouse wheel.
-I still experience crash when open new file.
-Saving Color template makes all colors black.
-CTRL+LMB routing doesn't work with "Multi selection" option. (because of CTRL?)
(1) I think we will colorize the identifier / number / operator /string, maybe it is not necessary.
(2)(3) Maybe more detail please...
(4) My mistake, I'll fix at next rev.
(5) If "Multi Selection" is "ON", the CTRL+LMB( Goto Definition ) will disable.
AWPStar
Posts: 47
Joined: May 03, 2009 21:47

Re: FreeBasic IDE-poseidonFB(Update 2021.10.05)

Post by AWPStar »

Kuan Hsu wrote:(1) I think we will colorize the identifier / number / operator /string, maybe it is not necessary.
That's a big. It was customisable in previous versions. Now i just got invisible(block) text with dark theme.
And not just some text. Even goto labels.
Kuan Hsu wrote:(2)(3) Maybe more detail please...
Sometimes IDE just crashes when i'm tring to open now file(via explorer). I don't have any details.
But it is annoying when you have several different files opened, trying to open another one and they all gone.
Kuan Hsu wrote:(5) If "Multi Selection" is "ON", the CTRL+LMB( Goto Definition ) will disable.
Is there a way to redinife "CTRL+LMB"? They both are really useful.
Kuan Hsu
Posts: 586
Joined: Sep 16, 2007 15:12
Location: Taiwan

Re: FreeBasic IDE-poseidonFB(Update 2021.10.05)

Post by Kuan Hsu »

AWPStar wrote: Jan 18, 2022 4:17
Kuan Hsu wrote:(1) I think we will colorize the identifier / number / operator /string, maybe it is not necessary.
That's a big. It was customisable in previous versions. Now i just got invisible(block) text with dark theme.
And not just some text. Even goto labels.
Kuan Hsu wrote:(2)(3) Maybe more detail please...
Sometimes IDE just crashes when i'm tring to open now file(via explorer). I don't have any details.
But it is annoying when you have several different files opened, trying to open another one and they all gone.
Kuan Hsu wrote:(5) If "Multi Selection" is "ON", the CTRL+LMB( Goto Definition ) will disable.
Is there a way to redinife "CTRL+LMB"? They both are really useful.
(1)OK, I'll add it at next rev.
(2)It still the BEX issue about the IUP.dll, I've tested it occur while file loading, but the codes about load file not use the IUP function, I've try to rewrite the file loading code and use iconc.dll to load unicode file and re-compiled iup.dll( off the DEP )...etc, if the issue still trigger, I'm sorry I've no idea how to fix it, I feel desperate...@@
(3) "Goto Definition" of "Goto Member Procedure", R-Click on the word and click the item of popup window or use short-cut.
UEZ
Posts: 972
Joined: May 05, 2017 19:59
Location: Germany

Re: FreeBasic IDE-poseidonFB(Update 2022.02.25)

Post by UEZ »

Hi Kuan Hsu,

it seems that "Contract All" for the function _ASM_ImageBlur doesn't work properly:

Code: Select all

Function _ASM_ImageBlur(pImage As Any Ptr, iRadius As Integer, iExpandEdge As Integer = 0) As Any Ptr 
   'By Eukalyptus / modified by D.J. Peters aka Joshy
   Dim As Long iW, iH, iPX, iPitch
   Dim As Any Ptr pData, pDataBlur, pDataTmp
   
   If Imageinfo(pImage, iW, iH, iPX, iPitch, pData) <> 0 Then Return 0
   If iPX <> 4 Then Return 0
   
   If iRadius < 0 Then
      iRadius = 0
   Elseif iRadius > 127 Then
      iRadius = 127
   Endif
   
   Dim As Any Ptr pImgBlur, pImgTmp
   If iExpandEdge <> 0 Then
      iW += iRadius * 2
      iH += iRadius * 2
   Endif
   
   pImgBlur = Imagecreate(iW, iH, 0, 32)
   pImgTmp = Imagecreate(iW, iH, 0, 32)
   
   Dim As Integer iWidth = iw, iHeight = iH 
   Dim As Integer iPitchBlur
   Dim As Long iPitchBlur_tmp
   
   Imageinfo(pImgBlur, , , , iPitchBlur_tmp, pDataBlur)
   Imageinfo(pImgTmp, , , , , pDataTmp)
   If pImgBlur = 0 Orelse pImgTmp = 0 Then
      Imagedestroy(pImgBlur)
      Imagedestroy(pImgTmp)
      Return 0
   End If
   iPitchBlur = iPitchBlur_tmp
   
   If iExpandEdge <> 0 Then
      Put pImgBlur, (iRadius, iRadius), pImage, Alpha
   Else
      Put pImgBlur, (0, 0), pImage, Alpha
   End If
  
#Ifndef __Fb_64bit__

  #Define REG_SIZE 4
  #Define REG_ACCESS DWORD
  #Define REG_AX eax
  #Define REG_BX ebx
  #Define REG_CX ecx
  #Define REG_DX edx
  #Define REG_DI edi
  #Define REG_SI esi
  #Define REG_SP esp
  #Define REG_BP ebp

#Else

  #Define REG_SIZE 8
  #Define REG_ACCESS QWORD
  #Define REG_AX rax
  #Define REG_BX rbx
  #Define REG_CX rcx
  #Define REG_DX rdx
  #Define REG_DI rdi
  #Define REG_SI rsi
  #Define REG_SP rsp
  #Define REG_BP rbp

#Endif

  #Define LOCAL_VAR_SPACE 16*REG_SIZE
  'esp/rsp = [X] [Y] [W] [H] [Stride] [R] [pDst] [pSrc] [pDstO] [pSrcO]
  
  #Define X_OFF    [REG_SP]
  #Define Y_OFF    [REG_SP+1*REG_SIZE]
  #Define W_OFF    [REG_SP+2*REG_SIZE]
  #Define H_OFF    [REG_SP+3*REG_SIZE]
  #Define S_OFF    [REG_SP+4*REG_SIZE]
  #Define R_OFF    [REG_SP+5*REG_SIZE]
  #Define DST_OFF  [REG_SP+6*REG_SIZE]
  #Define SRC_OFF  [REG_SP+7*REG_SIZE]
  #Define DSTO_OFF [REG_SP+8*REG_SIZE]
  #Define SRCO_OFF [REG_SP+9*REG_SIZE]
  
  
  Asm
  mov REG_CX, [iWidth]
  mov REG_BX, [iHeight]
  mov REG_DX, [iPitchBlur]
  mov REG_DI, [pDataTmp]
  mov REG_SI, [pDataBlur]
       
  mov REG_AX, [iRadius]
  inc REG_AX
  
  push REG_BP
  mov REG_BP, REG_AX
  Sub REG_SP, LOCAL_VAR_SPACE
 
  mov W_OFF,    REG_CX
  mov H_OFF,    REG_BX
  mov S_OFF,    REG_DX
  mov R_OFF,    REG_BP
  mov DST_OFF,  REG_DI
  mov DSTO_OFF, REG_DI
  mov SRC_OFF,  REG_SI
  mov SRCO_OFF, REG_SI  

  mov REG_AX, 0x47000000 'ByteToFloat MSK
  movd xmm7, REG_AX
  pshufd xmm7, xmm7, 0

  ' ####################################################
  ' # W-Loop
  ' ####################################################
   mov REG_BX, H_OFF
   mov Y_OFF, REG_BX

_Blur_LoopW:
  mov REG_DI, DST_OFF
  mov REG_SI, SRC_OFF
  mov REG_DX, S_OFF 'Stride
  Add REG_ACCESS Ptr DST_OFF, 4 'Next RowCol(Transform vertical<->horizontal)
  Add SRC_OFF, REG_DX 'Next Row

  mov REG_DX, H_OFF 'Y-Stride
  Shl REG_DX, 2

  pxor xmm6, xmm6 'Reset In-Out
  pxor xmm5, xmm5 'Reset Sum
  pxor xmm4, xmm4 'UnPack

  mov REG_AX, 0 'Reset SumDiv
  mov REG_BX, 0 'Reset DivInc
  ' ----------------------------------------------------
  ' | X-In += Next
  ' ----------------------------------------------------
  mov REG_BP, 0 'Offset
  mov REG_CX, R_OFF 'iR
  _Blur_LoopX_In:
    movd      xmm0, [REG_SI+REG_BP]
    punpcklbw xmm0, xmm4 '[ ][ ][ ][ ][An][Rn][Gn][Bn] Next
    paddw     xmm6, xmm0 'IN+=Next
    movdqa    xmm0, xmm6
    punpcklwd xmm0, xmm4 '[AI][RI][GI][BI]
    paddd     xmm5, xmm0 'Stack += IN

    Add REG_BX, 1 'SumDivInc += 1
    Add REG_AX, REG_BX 'SumDiv += Inc
    Add REG_BP, 4
    Sub REG_CX, 1
  jg _Blur_LoopX_In
  ' ----------------------------------------------------
  ' | XIn += Next / XIn -= Mid / XOut += Mid
  ' ----------------------------------------------------
  mov REG_CX, R_OFF 'iR
  _Blur_LoopX_InOut:
    cvtsi2ss  xmm3, REG_AX
    rcpss     xmm3, xmm3
    pshufd    xmm3, xmm3, 0 'SumDiv
    movdqa    xmm0, xmm5
    paddd     xmm0, xmm7 ' Ubyte -> Float
    subps     xmm0, xmm7 ' /
    mulps     xmm0, xmm3
    addps     xmm0, xmm7 ' Float -> Ubyte
    psubd     xmm0, xmm7 ' /
    packssdw  xmm0, xmm0 '[A][R][G][B][A][R][G][B]
    packuswb  xmm0, xmm0 '[ARGB][ARGB][ARGB][ARGB]
    movd      [REG_DI], xmm0
    movd      xmm0, [REG_SI+REG_BP]
    movd      xmm1, [REG_SI]
    punpcklbw xmm0, xmm4 '[ ][ ][ ][ ][An][Rn][Gn][Bn] Next
    punpcklbw xmm1, xmm4 '[ ][ ][ ][ ][Am][Rm][Gm][Bm] Mid
    movlhps   xmm0, xmm1 '[Am][Rm][Gm][Bm][An][Rn][Gn][Bn] = [Mid][Next]
    paddw     xmm6, xmm0 'Out+=Mid / IN+=Next
    psubw     xmm6, xmm1 '(Out-=Last) / IN-=Mid
    movdqa    xmm1, xmm6
    movdqa    xmm0, xmm6
    punpckhwd xmm1, xmm4 '[AO][RO][GO][BO]
    punpcklwd xmm0, xmm4 '[AI][RI][GI][BI]
    psubd     xmm5, xmm1 'Stack -= Out
    paddd     xmm5, xmm0 'Stack += IN
    Sub       REG_BX, 1 'SumDivInc += 1
    Add       REG_AX, REG_BX 'SumDiv += Inc
    Add       REG_SI, 4
    Add       REG_DI, REG_DX
    Sub       REG_CX, 1
  jg _Blur_LoopX_InOut

  cvtsi2ss  xmm3, REG_AX
  rcpss     xmm3, xmm3
  pshufd    xmm3, xmm3, 0 'SumDiv
  mov       REG_BX, REG_BP
  neg       REG_BX 'Last Index
  ' ----------------------------------------------------
  ' | XIn += Next / XIn -= Mid / XOut += Mid / XOut -= Last
  ' ----------------------------------------------------
  mov REG_CX, W_OFF 'iWidth
  Sub REG_CX, R_OFF
  Sub REG_CX, R_OFF
  _Blur_LoopX:
    movdqa    xmm0, xmm5
    paddd     xmm0, xmm7 ' Ubyte -> Float
    subps     xmm0, xmm7 ' /
    mulps     xmm0, xmm3
    addps     xmm0, xmm7 ' Float -> Ubyte
    psubd     xmm0, xmm7 ' /
    packssdw  xmm0, xmm0 '[A][R][G][B][A][R][G][B]
    packuswb  xmm0, xmm0 '[ARGB][ARGB][ARGB][ARGB]
    movd      [REG_DI], xmm0
    movd xmm0,[REG_SI+REG_BP]
    movd xmm1,[REG_SI]
    movd xmm2,[REG_SI+REG_BX]
    punpcklbw xmm0, xmm4 '[ ][ ][ ][ ][An][Rn][Gn][Bn] Next
    punpcklbw xmm1, xmm4 '[ ][ ][ ][ ][Am][Rm][Gm][Bm] Mid
    punpcklbw xmm2, xmm4 '[ ][ ][ ][ ][Al][Rl][Gl][Bl] Last
    movlhps   xmm0, xmm1 '[Am][Rm][Gm][Bm][An][Rn][Gn][Bn] = [Mid][Next]
    movlhps   xmm1, xmm2 '[Al][Rl][Gl][Bl][Ao][Ro][Go][Bo] = [Last][Mid]
    paddw     xmm6, xmm0 'Out+=Mid / IN+=Next
    psubw     xmm6, xmm1 'Out-=Last / IN-=Mid
    movdqa    xmm1, xmm6
    movdqa    xmm0, xmm6
    punpckhwd xmm1, xmm4 '[AO][RO][GO][BO]
    punpcklwd xmm0, xmm4 '[AI][RI][GI][BI]
    psubd     xmm5, xmm1 'Stack -= Out
    paddd     xmm5, xmm0 'Stack += IN
    Add       REG_SI, 4
    Add       REG_DI, REG_DX
    Sub       REG_CX, 1
  jg _Blur_LoopX
  ' ----------------------------------------------------
  ' | XIn -= Mid / XOut += Mid / XOut -= Last
  ' ----------------------------------------------------
  mov REG_BP, 0 'DivInc
  mov REG_CX, R_OFF 'iR
  _Blur_LoopX_Out:
    cvtsi2ss  xmm3, REG_AX
    rcpss     xmm3, xmm3
    pshufd    xmm3, xmm3, 0 'SumDiv
    movdqa    xmm0, xmm5
    paddd     xmm0, xmm7 ' Ubyte -> Float
    subps     xmm0, xmm7 ' /
    mulps     xmm0, xmm3
    addps     xmm0, xmm7 ' Float -> Ubyte
    psubd     xmm0, xmm7 ' /
    packssdw  xmm0, xmm0 '[A][R][G][B][A][R][G][B]
    packuswb  xmm0, xmm0 '[ARGB][ARGB][ARGB][ARGB]
    movd      [REG_DI], xmm0
    movd      xmm0, [REG_SI]
    movd      xmm1, [REG_SI+REG_BX]
    punpcklbw xmm0, xmm4 '[ ][ ][ ][ ][Am][Rm][Gm][Bm] Mid
    punpcklbw xmm1, xmm4 '[ ][ ][ ][ ][Al][Rl][Gl][Bl] Last
    movlhps   xmm0, xmm1 '[Al][Rl][Gl][Bl][Am][Rm][Gm][Bm] = [Last][Mid]
    psubw     xmm6, xmm0 'Out-=Last / IN-=Mid
    pslldq    xmm0, 8
    paddw     xmm6, xmm0 'Out+=Mid / (IN+=Next)
    movdqa    xmm1, xmm6
    movdqa    xmm0, xmm6
    punpckhwd xmm1, xmm4 '[AO][RO][GO][BO]
    punpcklwd xmm0, xmm4 '[AI][RI][GI][BI]
    psubd     xmm5, xmm1 'Stack -= Out
    paddd     xmm5, xmm0 'Stack += IN
    Add       REG_BP, 1
    Sub       REG_AX, REG_BP
    Add       REG_SI, 4
    Add       REG_DI, REG_DX
    Sub       REG_CX, 1
  jg _Blur_LoopX_Out

  Sub REG_ACCESS Ptr Y_OFF, 1
  jg _Blur_LoopW


  ' ####################################################
  ' # H-Loop
  ' ####################################################
  mov REG_DI, SRCO_OFF
  mov REG_SI, DSTO_OFF
  mov DST_OFF, REG_DI
  mov SRC_OFF, REG_SI

  mov REG_BX, W_OFF
  mov X_OFF, REG_BX
 _Blur_LoopH:
  mov REG_DI, DST_OFF
  mov REG_SI, SRC_OFF
  mov REG_DX, H_OFF
  Shl REG_DX, 2
  Add REG_ACCESS Ptr DST_OFF, 4 'Next Col
  Add SRC_OFF, REG_DX 'Next ColRow
  mov REG_DX, S_OFF 'Stride
  pxor xmm6, xmm6 'Reset In-Out
  pxor xmm5, xmm5 'Reset Sum
  pxor xmm4, xmm4 'UnPack
  mov REG_AX, 0 'Reset SumDiv
  mov REG_BX, 0 'Reset DivInc
  ' ----------------------------------------------------
  ' | X-In += Next
  ' ----------------------------------------------------
  mov REG_BP, 0 'Offset
  mov REG_CX, R_OFF 'iR
  
  _Blur_LoopY_In:
    movd xmm0, [REG_SI+REG_BP]
    punpcklbw xmm0, xmm4 '[ ][ ][ ][ ][An][Rn][Gn][Bn] Next
    paddw xmm6, xmm0 'IN+=Next
    movdqa xmm0, xmm6
    punpcklwd xmm0, xmm4 '[AI][RI][GI][BI]
    paddd xmm5, xmm0 'Stack += IN
    Add REG_BX, 1 'SumDivInc += 1
    Add REG_AX, REG_BX 'SumDiv += Inc
    Add REG_BP, 4
    Sub REG_CX, 1
  jg _Blur_LoopY_In

  ' ----------------------------------------------------
  ' | XIn += Next / XIn -= Mid / XOut += Mid
  ' ----------------------------------------------------
  mov REG_CX, R_OFF 'iR
  _Blur_LoopY_InOut:
    cvtsi2ss xmm3, REG_AX
    rcpss xmm3, xmm3
    pshufd xmm3, xmm3, 0 'SumDiv
    movdqa xmm0, xmm5
    paddd xmm0, xmm7 ' Ubyte -> Float
    subps xmm0, xmm7 '/
    mulps xmm0, xmm3
    addps xmm0, xmm7 ' Float -> Ubyte
    psubd xmm0, xmm7 '/
    packssdw xmm0, xmm0 '[A][R][G][B][A][R][G][B]
    packuswb xmm0, xmm0 '[ARGB][ARGB][ARGB][ARGB]
    movd [REG_DI], xmm0
    movd xmm0, [REG_SI+REG_BP]
    movd xmm1, [REG_SI]
    punpcklbw xmm0, xmm4 '[ ][ ][ ][ ][An][Rn][Gn][Bn] Next
    punpcklbw xmm1, xmm4 '[ ][ ][ ][ ][Am][Rm][Gm][Bm] Mid
    movlhps xmm0, xmm1 '[Am][Rm][Gm][Bm][An][Rn][Gn][Bn] = [Mid][Next]
    paddw xmm6, xmm0 'Out+=Mid / IN+=Next
    psubw xmm6, xmm1 '(Out-=Last) / IN-=Mid
    movdqa xmm1, xmm6
    movdqa xmm0, xmm6
    punpckhwd xmm1, xmm4 '[AO][RO][GO][BO]
    punpcklwd xmm0, xmm4 '[AI][RI][GI][BI]
    psubd xmm5, xmm1 'Stack -= Out
    paddd xmm5, xmm0 'Stack += IN
    Sub REG_BX, 1 'SumDivInc += 1
    Add REG_AX, REG_BX 'SumDiv += Inc
    Add REG_SI, 4
    Add REG_DI, REG_DX
    Sub REG_CX, 1
  jg _Blur_LoopY_InOut

  cvtsi2ss xmm3, REG_AX
  rcpss xmm3, xmm3
  pshufd xmm3, xmm3, 0 'SumDiv
  mov REG_BX, REG_BP
  neg REG_BX 'Last Index
  ' ----------------------------------------------------
  ' | XIn += Next / XIn -= Mid / XOut += Mid / XOut -= Last
  ' ----------------------------------------------------
  mov REG_CX, H_OFF 'iHeight
  Sub REG_CX, R_OFF
  Sub REG_CX, R_OFF
  _Blur_LoopY:
    movdqa xmm0, xmm5
    paddd xmm0, xmm7 ' Ubyte -> Float
    subps xmm0, xmm7 '/
    mulps xmm0, xmm3
    addps xmm0, xmm7 ' Float -> Ubyte
    psubd xmm0, xmm7 '/
    packssdw xmm0, xmm0 '[A][R][G][B][A][R][G][B]
    packuswb xmm0, xmm0 '[ARGB][ARGB][ARGB][ARGB]
    movd [REG_DI], xmm0
    movd xmm0, [REG_SI+REG_BP]
    movd xmm1, [REG_SI]
    movd xmm2, [REG_SI+REG_BX]
    punpcklbw xmm0, xmm4 '[ ][ ][ ][ ][An][Rn][Gn][Bn] Next
    punpcklbw xmm1, xmm4 '[ ][ ][ ][ ][Am][Rm][Gm][Bm] Mid
    punpcklbw xmm2, xmm4 '[ ][ ][ ][ ][Al][Rl][Gl][Bl] Last
    movlhps xmm0, xmm1 '[Am][Rm][Gm][Bm][An][Rn][Gn][Bn] = [Mid][Next]
    movlhps xmm1, xmm2 '[Al][Rl][Gl][Bl][Ao][Ro][Go][Bo] = [Last][Mid]
    paddw xmm6, xmm0 'Out+=Mid / IN+=Next
    psubw xmm6, xmm1 'Out-=Last / IN-=Mid
    movdqa xmm1, xmm6
    movdqa xmm0, xmm6
    punpckhwd xmm1, xmm4 '[AO][RO][GO][BO]
    punpcklwd xmm0, xmm4 '[AI][RI][GI][BI]
    psubd xmm5, xmm1 'Stack -= Out
    paddd xmm5, xmm0 'Stack += IN
    
    Add REG_SI, 4
    Add REG_DI, REG_DX
    Sub REG_CX, 1
  jg _Blur_LoopY
  ' ----------------------------------------------------
  ' | XIn -= Mid / XOut += Mid / XOut -= Last
  ' ----------------------------------------------------
  mov REG_BP, 0 'DivInc
  mov REG_CX, R_OFF 'iR
  _Blur_LoopY_Out:
    cvtsi2ss xmm3, REG_AX
    rcpss xmm3, xmm3
    pshufd xmm3, xmm3, 0 'SumDiv
    
    movdqa xmm0, xmm5
    paddd xmm0, xmm7 ' Ubyte -> Float
    subps xmm0, xmm7 '/
    mulps xmm0, xmm3
    addps xmm0, xmm7 ' Float -> Ubyte
    psubd xmm0, xmm7 '/
    packssdw xmm0, xmm0 '[A][R][G][B][A][R][G][B]
    packuswb xmm0, xmm0 '[ARGB][ARGB][ARGB][ARGB]
    movd [REG_DI], xmm0
    
    movd xmm0, [REG_SI]
    movd xmm1, [REG_SI+REG_BX]
    punpcklbw xmm0, xmm4 '[ ][ ][ ][ ][Am][Rm][Gm][Bm] Mid
    punpcklbw xmm1, xmm4 '[ ][ ][ ][ ][Al][Rl][Gl][Bl] Last
    movlhps xmm0, xmm1 '[Al][Rl][Gl][Bl][Am][Rm][Gm][Bm] = [Last][Mid]
    psubw xmm6, xmm0 'Out-=Last / IN-=Mid
    pslldq xmm0, 8
    paddw xmm6, xmm0 'Out+=Mid / (IN+=Next)
    movdqa xmm1, xmm6
    movdqa xmm0, xmm6
    punpckhwd xmm1, xmm4 '[AO][RO][GO][BO]
    punpcklwd xmm0, xmm4 '[AI][RI][GI][BI]
    psubd xmm5, xmm1 'Stack -= Out
    paddd xmm5, xmm0 'Stack += IN
    
    Add REG_BP, 1
    Sub REG_AX, REG_BP
    
    Add REG_SI, 4
    Add REG_DI, REG_DX
    Sub REG_CX, 1
  jg _Blur_LoopY_Out

  Sub REG_ACCESS Ptr X_OFF, 1
 jg _Blur_LoopH

  Add REG_SP, LOCAL_VAR_SPACE
  pop REG_BP

  End Asm
  Imagedestroy(pImgTmp)
  Return pImgBlur
End Function


Sub ImageContrast(pImage as any Pointer, contrast as Integer, brightness as Integer = 0, iW As Ushort, iH As Ushort)
   #Define Red(colour) ((colors Shr 16) And 255)
   #Define Green(colour) ((colors Shr 8) And 255)
   #Define Blue(colour) (colors And 255)
   #Define Truncate(colour) (Iif(colour < 0, 0, Iif(colour > 255, 255, CUbyte(colour))))
   Dim as Ulong colors
   Dim As Integer w, h, pitch
   Dim As Any Pointer pixdata
   Imageinfo(pImage, w, h, , pitch, pixdata)
   
   Dim as Single factor, contrastLevel = (((100.0 + contrast) / 100.0) * ((100.0 + contrast) / 100.0))

   For y as UShort = 0 to iH - 1
      For x as Ushort = 0 to iW - 1
         colors = *CPtr(ULong ptr, pixdata + y * pitch + x Shl 2)
 
         *CPtr(ULong ptr, pixdata + y * pitch + x Shl 2) = RGB(Truncate(brightness + (((Red(colour) / 255 - 0.5) * contrastLevel) + 0.5) * 255.0), _
                                                               Truncate(brightness + (((Green(colour) / 255 - 0.5) * contrastLevel) + 0.5) * 255.0), _
                                                               Truncate(brightness + (((Blue(colour) / 255 - 0.5) * contrastLevel) + 0.5) * 255.0))
      Next
   Next
End Sub


? "Contract All"
If you contract all then the next functions will be hidden. I know that it might be difficult because of the ASM commands which uses also FB.

Thx.
Post Reply