Author Topic: Pipecom Browser for Filename$  (Read 8523 times)

0 Members and 1 Guest are viewing this topic.

Offline bplus

  • Global Moderator
  • Forum Resident
  • Posts: 8053
  • b = b + ...
    • View Profile
Pipecom Browser for Filename$
« on: February 07, 2021, 08:04:56 pm »
Here is application to viewing BMP24 files that NOVARSEG started:
Code: QB64: [Select]
  1. _Title "Pipecom Browser for BMP24 File Display" 'b+ testing one array system with pipecom
  2. ' Thanks to Spriggsy, Zak, for convincing me pipecom is better!
  3. ' Using Steve's fixed BMP24 loader
  4. ' Also thanks to Dav for 1 window for file and folder selection idea
  5. ' Also thanks to NOVARSEG who got me going on this for a better filename$ retriever
  6.  
  7. Declare Library "pipecom"
  8.     Function pipecom$ (cmd As String)
  9.  
  10. Screen _NewImage(1280, 740, 32)
  11. _Delay .25
  12. _ScreenMove 65, 0 ' your screen might need different
  13.  
  14. ReDim myFile$, image&
  15. ReDim As Long col, row, charW, charH
  16. Color , &HFF000033
  17. Do 'test our new function
  18.     ScnState 0
  19.     col = 16: row = 3: charW = 128: charH = 40
  20.     myFile$ = GetFileName$(row, col, charW, charH)
  21.     ScnState -1 ' <<<<<<<<<<<<<<<<<<<<<<<<<<< this is supposed to restore back color
  22.     image& = loadBMP24&(myFile$)
  23.     Color , &HFF000033
  24.     Cls
  25.     If image& <> 0 Then
  26.         _Title myFile$ + " press any to get another BMP24 file image, esc to quit"
  27.         _PutImage ((_Width - _Width(image&)) / 2, (_Height - _Height(image&)) / 2)-Step(_Width(image&), _Height(image&)), image&, 0
  28.         Sleep
  29.         _FreeImage image&
  30.     End If
  31.  
  32. Function loadBMP24& (Filename$) ' Steve's revised version without the extra handle and memory leak
  33.     Dim As _Unsigned Long of, l, w, r, c
  34.     Dim a As _MEM
  35.     Dim As Long handle, h ' <<< edit as per NOVARSEG
  36.     Dim tt As String * 4
  37.     Dim t As String * 3
  38.     Dim padding$
  39.  
  40.     If Right$(UCase$(Filename$), 4) <> ".BMP" Then Exit Function
  41.     Print Filename$
  42.     Open Filename$ For Binary As #1
  43.     Get #1, 11, of
  44.     Get #1, 15, l
  45.     Get #1, , w
  46.     Get #1, , h
  47.     Get #1, , i
  48.     Get #1, , i 'get I twice ???
  49.     If i <> 24 Then Exit Function
  50.     handle = _NewImage(w, h, 32)
  51.     a = _MemImage(handle)
  52.     If ((w * 3) Mod 4) <> 0 Then padding$ = Space$((4 - ((w * 3) Mod 4))) '’need padding pixels
  53.     Seek #1, of + 1 'go to the offset where the data starts
  54.     For r = h - 1 To 0 Step -1 'from the bottom to top
  55.         For c = 0 To w - 1 'left to right
  56.             Get #1, , t 'get the data sequentially
  57.             tt = t + Chr$(255)
  58.             _MemPut a, a.OFFSET + (w * r + c) * 4, tt
  59.         Next c
  60.         Get #1, , padding$ 'Get the padding at the end of the line
  61.     Next r
  62.     Close
  63.     loadBMP24& = handle
  64.     _MemFree a
  65.  
  66. Function GetFileName$ (LocateR, LocateC, CharWide, CharHigh) ' < careful Locate Row, Col NOT x, y
  67.     'This Funtion needs:
  68.     ' pipecom.h in same folder as QB64.exe
  69.     ' This in main code section near top:
  70.     ' Declare Library "pipecom"
  71.     '    Function pipecom$ (cmd As String)
  72.     ' End Declare
  73.     ' sub  Split source$, delimiter$, arr$()
  74.     ' function GetArrayItem$(x, y, w, h, arr$())
  75.  
  76.     ReDim As String d, s, dr
  77.     ReDim As _Unsigned Long fc, bc
  78.     fc = _DefaultColor: bc = _BackgroundColor ' save colors
  79.     Getfolder:
  80.     Color fc, bc: Cls
  81.     d = pipecom("dir /n /o:gend") '/n files on right (40) /o = order g for group dirs first, e extension, name, date
  82.     d = Left$(d, Len(d) - 1) ' always ends with delimiter
  83.     ReDim dir(1 To 1) As String
  84.     Split d, Chr$(10), dir()
  85.     s = GetArrayItem$(LocateR, LocateC, CharWide, CharHigh, dir())
  86.     If InStr(s, "<DIR>") Then 'isolate name
  87.         dr = _Trim$(Mid$(s, InStr(s, "<DIR>") + 6))
  88.         ChDir dr
  89.         GoTo Getfolder
  90.     ElseIf InStr(s, "AM") Or InStr(s, "PM") Then
  91.         GetFileName$ = _Trim$(Mid$(s, 40))
  92.         Color fc, bc: Cls
  93.     ElseIf s = "" Then 'cancel, escape, bad line
  94.         Color fc, bc: Cls ' will return empty string
  95.     End If
  96.  
  97. Sub Split (SplitMeString As String, delim As String, loadMeArray() As String)
  98.     Dim curpos As Long, arrpos As Long, LD As Long, dpos As Long 'fix use the Lbound the array already has
  99.     curpos = 1: arrpos = LBound(loadMeArray): LD = Len(delim)
  100.     dpos = InStr(curpos, SplitMeString, delim)
  101.     Do Until dpos = 0
  102.         loadMeArray(arrpos) = Mid$(SplitMeString, curpos, dpos - curpos)
  103.         arrpos = arrpos + 1
  104.         If arrpos > UBound(loadMeArray) Then ReDim _Preserve loadMeArray(LBound(loadMeArray) To UBound(loadMeArray) + 1000) As String
  105.         curpos = dpos + LD
  106.         dpos = InStr(curpos, SplitMeString, delim)
  107.     Loop
  108.     loadMeArray(arrpos) = Mid$(SplitMeString, curpos)
  109.     ReDim _Preserve loadMeArray(LBound(loadMeArray) To arrpos) As String 'get the ubound correct
  110.  
  111.  
  112. ' Help: all this I hope is intuitive so Help window is provided
  113. ' "Mouse, mouse wheel, and arrow keys should work as expected for item selection."
  114. ' "Press spacebar to select a highlighted item or just click it."
  115. ' "Use number(s) + enter to select an array item by it's index number,"
  116. ' "backspace will remove last number pressed, delete will clear a number started.
  117. ' "Numbers started are shown in bottom right PgDn bar."
  118. ' "Enter will also select the highlighted item, if no number has been started."
  119. ' "Home starts you at lowest array index, End highlights then highest index."
  120. ' "Use PgUp and PgDn keys to flip through pages of array items."
  121. '
  122. ' Escape to Cancel Return "" else Return the selected string from the array
  123. Function GetArrayItem$ (LocateRoww, LocateColumn, BoxWidth, BoxHeight, Arr() As String)
  124.     'Notes: locateRow, locateColumn for top right corner of selection box on screen in characters for LOCATE.
  125.     'boxWidth and boxHeight are in character units, again for locate and print at correct places.
  126.     'All displaying is restricted to inside the box, which has PgUP and PgDn as top and bottom lines in the display.
  127.  
  128.     ReDim As Long maxWidth, maxHeight, page, hlite, mx, my, locateRow, lastMX, lastMY, row, mb
  129.     ReDim As Long lba, uba, choice, kh, index
  130.     Dim clrStr As String, b As String
  131.  
  132.     'ScnState 0 ' use out side this function before and after
  133.     locateRow = LocateRoww + 1 'fix a miscalc in coding
  134.     maxWidth = BoxWidth '       number of characters in box
  135.     maxHeight = BoxHeight - 2 ' number of lines displayed of array at one time = 1 page
  136.     lba = LBound(arr)
  137.     uba = UBound(arr)
  138.     page = 0
  139.     hlite = 0 '                 line in display ready for selection by spacebar or if no number is started, enter
  140.     clrStr$ = Space$(maxWidth) 'clearing a display line
  141.  
  142.     GoSub update '              show the beginning of the array items for selection
  143.     choice = -1719
  144.     Do 'until get a selection or demand exit
  145.  
  146.         'handle the key stuff
  147.         kh& = _KeyHit
  148.         If kh& Then
  149.             If kh& > 0 And kh& < 255 Then
  150.                 If InStr("0123456789", Chr$(kh&)) > 0 Then
  151.                     b$ = b$ + Chr$(kh&): GoSub update
  152.                 ElseIf kh& = 13 Then 'enter pressed check if number is being entered?
  153.                     If Len(b$) Then
  154.                         If Val(b$) >= lba And Val(b$) <= uba Then 'we have number started
  155.                             choice = Val(b$): Exit Do
  156.                         Else 'clear b$ to show some response to enter
  157.                             b$ = "": GoSub update 'clear the value that doesn't work
  158.                         End If
  159.                     Else
  160.                         choice = hlite + page * maxHeight + lba 'must mean to select the highlighted item
  161.                     End If
  162.                 ElseIf kh& = 27 Then
  163.                     Exit Do 'escape clause offered to Cancel selection process
  164.                 ElseIf kh& = 32 Then
  165.                     choice = hlite + page * maxHeight + lba 'best way to choose highlighted selection
  166.                 ElseIf kh& = 8 Then 'backspace to edit number
  167.                     If Len(b$) Then b$ = Left$(b$, Len(b$) - 1): GoSub update
  168.                 End If
  169.             Else
  170.                 Select Case kh& 'choosing sections of array to display and highlighted item
  171.                     Case 21248 ' delete so clear b$
  172.                         b$ = "": GoSub update
  173.                     Case 20736 ' pg dn
  174.                         If (page + 1) * maxHeight + lba <= uba Then page = page + 1: GoSub update
  175.                     Case 18688 ' pg up
  176.                         If (page - 1) * maxHeight + lba >= lba Then page = page - 1: GoSub update
  177.                     Case 18432 ' up
  178.                         If hlite - 1 < 0 Then
  179.                             If page > 0 Then
  180.                                 page = page - 1: hlite = maxHeight - 1: GoSub update
  181.                             End If
  182.                         Else
  183.                             hlite = hlite - 1: GoSub update
  184.                         End If
  185.                     Case 20480 'down
  186.                         If (hlite + 1) + page * maxHeight + lba <= uba Then 'ok to move up
  187.                             If hlite + 1 > maxHeight - 1 Then
  188.                                 page = page + 1: hlite = 0: GoSub update
  189.                             Else
  190.                                 hlite = hlite + 1: GoSub update
  191.                             End If
  192.                         End If
  193.                     Case 18176 'home
  194.                         page = 0: hlite = 0: GoSub update
  195.                     Case 20224 ' end
  196.                         page = Int((uba - lba) / maxHeight): hlite = maxHeight - 1: GoSub update
  197.                 End Select
  198.             End If
  199.         End If
  200.  
  201.         'handle the mouse stuff
  202.         While _MouseInput
  203.             If _MouseWheel = -1 Then 'up?
  204.                 If hlite - 1 < 0 Then
  205.                     If page > 0 Then
  206.                         page = page - 1: hlite = maxHeight - 1: GoSub update
  207.                     End If
  208.                 Else
  209.                     hlite = hlite - 1: GoSub update
  210.                 End If
  211.             ElseIf _MouseWheel = 1 Then 'down?
  212.                 If (hlite + 1) + page * maxHeight + lba <= uba Then 'ok to move up
  213.                     If hlite + 1 > maxHeight - 1 Then
  214.                         page = page + 1: hlite = 0: GoSub update
  215.                     Else
  216.                         hlite = hlite + 1: GoSub update
  217.                     End If
  218.                 End If
  219.             End If
  220.         Wend
  221.         mx = Int((_MouseX - LocateColumn * 8) / 8) + 2: my = Int((_MouseY - locateRow * 16) / 16) + 2
  222.         If _MouseButton(1) Then 'click contols or select array item
  223.             'clear mouse clicks
  224.             mb = _MouseButton(1)
  225.             If mb Then 'clear it
  226.                 While mb 'OK!
  227.                     If _MouseInput Then mb = _MouseButton(1)
  228.                     _Limit 100
  229.                 Wend
  230.             End If
  231.  
  232.             If mx >= 1 And mx <= maxWidth And my >= 1 And my <= maxHeight Then
  233.                 choice = my + page * maxHeight + lba - 1 'select item clicked
  234.             ElseIf mx >= 1 And mx <= maxWidth And my = 0 Then 'page up or exit
  235.                 If my = 0 And (mx <= maxWidth And mx >= maxWidth - 2) Then 'exit sign
  236.                     Exit Do 'escape plan for mouse click top right corner of display box
  237.                 Else 'PgUp bar clicked
  238.                     If (page - 1) * maxHeight + lba >= lba Then page = page - 1: GoSub update
  239.                 End If
  240.             ElseIf mx >= 1 And mx <= maxWidth And my = maxHeight + 1 Then 'page down bar clicked
  241.                 If (page + 1) * maxHeight + lba <= uba Then page = page + 1: GoSub update
  242.             End If
  243.         Else '   mouse over highlighting, only if mouse has moved!
  244.             If mx >= 1 And mx <= maxWidth And my >= 1 And my <= maxHeight Then
  245.                 If mx <> lastMX Or my <> lastMY Then
  246.                     If my - 1 <> hlite And (my - 1 + page * maxHeight + lba <= uba) Then
  247.                         hlite = my - 1
  248.                         lastMX = mx: lastMY = my
  249.                         GoSub update
  250.                     End If
  251.                 End If
  252.             End If
  253.         End If
  254.         _Limit 200
  255.     Loop Until choice >= lba And choice <= uba
  256.     If choice <> -1719 Then GetArrayItem$ = Arr(choice) 'set function and restore screen
  257.     'ScnState -1 'restore
  258.  
  259.     'display of array sections and controls on screen  ====================================================
  260.     update:
  261.  
  262.     'fix hlite if it has dropped below last array item
  263.     While hlite + page * maxHeight + lba > uba
  264.         hlite = hlite - 1
  265.     Wend
  266.  
  267.     'main display of array items at page * maxHeight (lines high)
  268.     For row = 0 To maxHeight - 1
  269.         If hlite = row Then Color _RGB(200, 200, 255), _RGB32(0, 0, 88) Else Color _RGB32(0, 0, 88), _RGB(200, 200, 255)
  270.         Locate locateRow + row, LocateColumn: Print clrStr$;
  271.         index = row + page * maxHeight + lba
  272.         If index >= lba And index <= uba Then
  273.             Locate locateRow + row, LocateColumn
  274.             Print Left$(LTrim$(Str$(index)) + ") " + Arr(index), maxWidth);
  275.         End If
  276.     Next
  277.  
  278.     'make page up and down bars to click, print PgUp / PgDn if available
  279.     Color _RGB32(200, 200, 255), _RGB32(0, 100, 50)
  280.     Locate locateRow - 1, LocateColumn: Print Space$(maxWidth);
  281.     If page <> 0 Then Locate locateRow - 1, LocateColumn: Print Left$(" Pg Up" + Space$(maxWidth), maxWidth);
  282.     Locate locateRow + maxHeight, LocateColumn: Print Space$(maxWidth);
  283.     If page <> Int(uba / maxHeight) Then
  284.         Locate locateRow + maxHeight, LocateColumn: Print Left$(" Pg Dn" + Space$(maxWidth), maxWidth);
  285.     End If
  286.     'make exit sign for mouse click
  287.     Color _RGB32(255, 255, 255), _RGB32(200, 100, 0)
  288.     Locate locateRow - 1, LocateColumn + maxWidth - 3
  289.     Print " X ";
  290.  
  291.     'if a number selection has been started show it's build = b$
  292.     If Len(b$) Then
  293.         Color _RGB(255, 255, 0), _RGB32(0, 0, 0)
  294.         Locate locateRow + maxHeight, LocateColumn + maxWidth - Len(b$) - 1
  295.         Print b$;
  296.     End If
  297.     _Display
  298.     _Limit 100
  299.     Return
  300.  
  301. Sub ScnState (restoreTF As Long) 'Thanks Steve McNeill  should we get a snap shot of screen?
  302.     Static As _Unsigned Long defaultColor, backGroundColor
  303.     Static As Long font, dest, source, row, col, autodisplay, mb, snap
  304.     If restoreTF Then
  305.         _Font font
  306.         Color defaultColor, backGroundColor
  307.         _Dest dest
  308.         _Source source
  309.  
  310.         _KeyClear
  311.         While _MouseInput: Wend 'clear mouse clicks
  312.         mb = _MouseButton(1)
  313.         If mb Then 'need this if line ?
  314.             Do
  315.                 While _MouseInput: Wend
  316.                 mb = _MouseButton(1)
  317.                 _Limit 100
  318.             Loop Until mb = 0
  319.         End If
  320.         _PutImage , snap, dest
  321.         _FreeImage snap
  322.         _Display
  323.         If autodisplay Then _AutoDisplay Else _Display
  324.         Locate row, col
  325.     Else
  326.         snap = _NewImage(_Width, _Height, 32)
  327.         _PutImage , 0, snap
  328.         font = _Font: defaultColor = _DefaultColor: backGroundColor = _BackgroundColor
  329.         dest = _Dest: source = _Source
  330.         row = CsrLin: col = Pos(0): autodisplay = _AutoDisplay
  331.         While _MouseInput: Wend 'clear mouse clicks
  332.         mb = _MouseButton(1)
  333.         If mb Then 'need this if line ?
  334.             Do
  335.                 While _MouseInput: Wend
  336.                 mb = _MouseButton(1)
  337.                 _Limit 100
  338.             Loop Until mb = 0
  339.         End If
  340.         _KeyClear
  341.     End If
  342.  
  343.  
  344.  
  345.  
  346.  

You will need this in your QB64.exe Folder and a QB64 version dev 1.5 version.


EDIT: made h Long in LoadBMP24 Sub as per NOVARSEG
* pipecom.h (Filesize: 0.45 KB, Downloads: 116)
« Last Edit: February 08, 2021, 12:33:49 pm by bplus »

Offline SpriggsySpriggs

  • Forum Resident
  • Posts: 1145
  • Larger than life
    • View Profile
    • GitHub
Re: Pipecom Browser for Filename$
« Reply #1 on: February 07, 2021, 08:06:18 pm »
@bplus It's cool that you were able to use my pipecom library to make something neat
Shuwatch!

Offline bplus

  • Global Moderator
  • Forum Resident
  • Posts: 8053
  • b = b + ...
    • View Profile
Re: Pipecom Browser for Filename$
« Reply #2 on: February 07, 2021, 08:08:47 pm »
Tell me you tried it already! ;-))

I just got done editing a thankyou to you. :)
« Last Edit: February 07, 2021, 08:16:01 pm by bplus »

Offline SpriggsySpriggs

  • Forum Resident
  • Posts: 1145
  • Larger than life
    • View Profile
    • GitHub
Re: Pipecom Browser for Filename$
« Reply #3 on: February 07, 2021, 09:32:33 pm »
@bplus It works great! Super fast on my system. Good job on the UI
Shuwatch!

Offline STxAxTIC

  • Library Staff
  • Forum Resident
  • Posts: 1091
  • he lives
    • View Profile
Re: Pipecom Browser for Filename$
« Reply #4 on: February 07, 2021, 10:25:49 pm »
well this is nice!
You're not done when it works, you're done when it's right.

Offline NOVARSEG

  • Forum Resident
  • Posts: 509
    • View Profile
Re: Pipecom Browser for Filename$
« Reply #5 on: February 08, 2021, 02:53:57 am »
@bplus
got to get latest version.

Yes it is true Steve did fix the padding issue.    Evidently some BMPs have a negative height value so you gotta change the
 
h  in 
Dim As _Unsigned Long of, l, w, h, r, c

to a LONG

I've never come across a negative height BMP though.. See my latest BMP viewer code that handles negative height BMPs

https://www.qb64.org/forum/index.php?topic=3602.30#lastPost
« Last Edit: February 08, 2021, 02:56:21 am by NOVARSEG »

Offline Dav

  • Forum Resident
  • Posts: 792
    • View Profile
Re: Pipecom Browser for Filename$
« Reply #6 on: February 08, 2021, 07:39:53 am »
Works great here!  Fast too.  I like it.

- Dav

Offline bplus

  • Global Moderator
  • Forum Resident
  • Posts: 8053
  • b = b + ...
    • View Profile
Re: Pipecom Browser for Filename$
« Reply #7 on: February 08, 2021, 12:16:12 pm »
Thanks for your feedback!

If someone could provide a Linux command that produces a Directory Listing that distinguishes Files from Folders and provides a Sample Output Directory, I could adapt this for Linux.

@johnno56  can you help with this?

Here simple Pipecom code to test commands to OS and Sample Output from Windows that I see all Files and Folders and can distingush Folders have <DIR> in label.
Code: [Select]
_Title "Quick Pipecom Demo" 'b+ 2021-02-08
Declare Library "pipecom"
    Function pipecom$ (cmd As String)
End Declare

Dim F As String 'tests with command line dir calls
' NOTE: these slants work \    these do not /
'F = pipecom("dir " + Chr$(34) + "C:\users\marka\desktop\QB64 work\000 work QB64" + Chr$(34) + " /b /A:D") ' Linux needs other switches
'F = pipecom("dir /b *.BAS") 'if you need just the filenames and not the rest of the output
'F = pipecom("dir /b /A:D") ' /b = bare list /A:D directories only

F = pipecom("dir ??? ") ' <<<<<<<<<<< Linux command goes between quotes here
Print F
_Clipboard$ = F


' Paste from ClipBoard
' Volume in drive C is Windows
' Volume Serial Number is 0EDF-FD28

' Directory of C:\Users\marka\Desktop\QB64 work\000 work QB64\000 Test\DIR$() replacement Spriggsy

'02/08/2021  12:14 PM    <DIR>          .
'02/08/2021  12:14 PM    <DIR>          ..
'10/26/2020  10:14 AM    <DIR>          pipecom.h bak
'02/07/2021  08:43 PM            14,491 Pipecom Browser mod 2 Better Array Select.bas
'02/06/2021  12:56 AM             1,015 Pipecom demo to replace Dir$() by Spriggsy.bas
'02/07/2021  08:54 PM             4,160 Pipecome Browser 1 Crude Keypress Select.bas
'02/08/2021  12:12 PM                 2 Quick Pipecom demo.bas
'01/19/2021  10:45 AM             2,548 Really simple pipe to clip by doppler.bas
'02/07/2021  12:00 PM             2,180 Shell dir to clipboard doppler.bas
'02/07/2021  08:35 PM         2,110,464 Pipecom Browser mod 2 Better Array Select.exe
'02/07/2021  08:53 PM         2,094,592 Pipecome Browser 1 Crude Keypress Select.exe
'02/08/2021  12:14 PM         2,080,256 Quick Pipecom demo.exe
'02/07/2021  11:59 AM         2,085,888 Really simple pipe to clip by doppler.exe
'02/07/2021  12:00 PM         2,087,424 Shell dir to clipboard doppler.exe
'              11 File(s)     10,483,020 bytes
'               3 Dir(s)  907,052,933,120 bytes free



Again put this into the same Folder as your QB64.exe
* pipecom.h (Filesize: 0.45 KB, Downloads: 117)
« Last Edit: February 08, 2021, 12:36:45 pm by bplus »

Offline bplus

  • Global Moderator
  • Forum Resident
  • Posts: 8053
  • b = b + ...
    • View Profile
Re: Pipecom Browser for Filename$
« Reply #8 on: February 08, 2021, 12:34:40 pm »
@bplus
got to get latest version.

Yes it is true Steve did fix the padding issue.    Evidently some BMPs have a negative height value so you gotta change the
 
h  in 
Dim As _Unsigned Long of, l, w, h, r, c

to a LONG

I've never come across a negative height BMP though.. See my latest BMP viewer code that handles negative height BMPs

https://www.qb64.org/forum/index.php?topic=3602.30#lastPost

OK edited the original post, thanks

Offline NOVARSEG

  • Forum Resident
  • Posts: 509
    • View Profile
Re: Pipecom Browser for Filename$
« Reply #9 on: February 08, 2021, 06:01:08 pm »
@bplus
Did you actually try it with -h?

If it works, a normal BMP image (with positive h)  will be upside down.

Dim padding$
 h = 0 - h   ' *** add this line ***
If Right$(UCase$(Filename$), 4) <> ".BMP" Then Exit Function
« Last Edit: February 08, 2021, 06:02:49 pm by NOVARSEG »

Offline bplus

  • Global Moderator
  • Forum Resident
  • Posts: 8053
  • b = b + ...
    • View Profile
Re: Pipecom Browser for Filename$
« Reply #10 on: February 08, 2021, 06:52:38 pm »
@bplus
Did you actually try it with -h?

If it works, a normal BMP image (with positive h)  will be upside down.

Dim padding$
 h = 0 - h   ' *** add this line ***
If Right$(UCase$(Filename$), 4) <> ".BMP" Then Exit Function

I changed the type of h to Long and tested the pictures I had and ran fine.

Now if h is a negative number it will work, I assume. I need an BMP24 file with h <0 pic to test that situation..

Offline NOVARSEG

  • Forum Resident
  • Posts: 509
    • View Profile
Re: Pipecom Browser for Filename$
« Reply #11 on: February 08, 2021, 07:05:50 pm »
Quote
Now if h is a negative number it will work, I assume. I need an BMP24 file with h <0 pic to test that situation.
.

Don't need an actual -h BMP to test

Dim padding$
 h = 0 - h   ' *** add this line. For testing only ***
If Right$(UCase$(Filename$), 4) <> ".BMP" Then Exit Function

If the code works then a BMP with +h will display upside down

with commented
  ' h = 0 - h

A BMP with actual -h will now display properly

****
for one thing

handle = _NewImage(w, h, 32)

can't have a negative h


https://www.qb64.org/forum/index.php?topic=3602.30#lastPost

« Last Edit: February 08, 2021, 07:24:54 pm by NOVARSEG »

Offline bplus

  • Global Moderator
  • Forum Resident
  • Posts: 8053
  • b = b + ...
    • View Profile
Re: Pipecom Browser for Filename$
« Reply #12 on: February 08, 2021, 09:40:24 pm »
.

Don't need an actual -h BMP to test

Dim padding$
 h = 0 - h   ' *** add this line. For testing only ***
If Right$(UCase$(Filename$), 4) <> ".BMP" Then Exit Function

If the code works then a BMP with +h will display upside down

with commented
  ' h = 0 - h

A BMP with actual -h will now display properly

****
for one thing

handle = _NewImage(w, h, 32)

can't have a negative h


https://www.qb64.org/forum/index.php?topic=3602.30#lastPost



I'm not messing around with all that if it is enough to make h long. The point of this thread is to test Pipecom and filename retriever code, I just happened to use BMP24 files because it was recent and you @NOVARSEG asked about  mouse input app for you code.

I will be glad to test a -h BMP24 file if one were provided with this app as it is. :)


Offline SMcNeill

  • QB64 Developer
  • Forum Resident
  • Posts: 3972
    • View Profile
    • Steve’s QB64 Archive Forum
Re: Pipecom Browser for Filename$
« Reply #13 on: February 08, 2021, 09:47:04 pm »
If you do get a -h file, just read it as usual and then _PUTIMAGE it from bottom to top to your screen.
https://github.com/SteveMcNeill/Steve64 — A github collection of all things Steve!

Offline NOVARSEG

  • Forum Resident
  • Posts: 509
    • View Profile
Re: Pipecom Browser for Filename$
« Reply #14 on: February 08, 2021, 10:35:44 pm »
@bplus

That will be a fair test of the code

I will make a -h BMP convertor. It will take a +h BMP and then convert it into a -h BMP

https://www.mozilla.org/en-US/security/advisories/mfsa2012-61/

here is an interesting one. MS paint evidently crashes with -h BMPs
https://groups.google.com/g/microsoft.public.win32.programmer.gdi/c/8CnUgn-gzD0/m/FS8rzRXq9DgJ

OK i tried engine3.bmp  in MSPAINT and it worked .
« Last Edit: February 09, 2021, 12:17:09 am by NOVARSEG »