Skip to content

Commit

Permalink
Clean up recent code additions
Browse files Browse the repository at this point in the history
Remove unused variables, fix silly typos, etc
  • Loading branch information
tannerhelland committed Mar 22, 2024
1 parent 11867fb commit 60be812
Show file tree
Hide file tree
Showing 7 changed files with 10 additions and 28 deletions.
12 changes: 1 addition & 11 deletions Classes/pdPDF.cls
Expand Up @@ -411,17 +411,7 @@ Friend Sub RenderCurrentPageToPDDib(ByRef dstDIB As pdDIB, ByVal dstLeft As Long
Exit Sub
End If

'PDFium can render to a few different pixel formats
' More DIB formats
' Unknown or unsupported format.
Const FPDFBitmap_Unknown = 0
' Gray scale bitmap, one byte per pixel.
Const FPDFBitmap_Gray = 1
' 3 bytes per pixel, byte order: blue, green, red.
Const FPDFBitmap_BGR = 2
' 4 bytes per pixel, byte order: blue, green, red, unused.
Const FPDFBitmap_BGRx = 3
' 4 bytes per pixel, byte order: blue, green, red, alpha.
'PDFium can render to a few different pixel formats; we only need BGRA for PD
Const FPDFBitmap_BGRA = 4

'Wrap a PDFium bitmap around the pdDIB object
Expand Down
10 changes: 5 additions & 5 deletions Classes/pdXBM.cls
Expand Up @@ -19,7 +19,7 @@ Attribute VB_Exposed = False
'Last update: wrap up initial build
'
'The XBM file format is *ancient*. PhotoDemon originally just handed XBM support off to the 3rd-party
' FreeImage library, but FreeImage crashes on pretety much all XBM files (including modern exported ones
' FreeImage library, but FreeImage crashes on pretty much all XBM files (including modern exported ones
' from well-known software like GIMP).
'
'So in 2024, I wrote my own XBM decoder. It definitely falls on the "quick-and-dirty" side of things,
Expand Down Expand Up @@ -55,12 +55,10 @@ Private m_Width As Long, m_Height As Long
'Byte-by-byte access is provided, as always, by a pdStream instance.
Private m_Stream As pdStream

'The last filename loaded. The contents of the filename will be stored in m_FileAsString, below.
'The last filename loaded. We use this to skip validation during loading, if the caller already called
' IsFileXBM on the current filename they want loaded.
Private m_OpenFilename As String

'Once the file is validated, its raw text is dumped into this string.
Private m_FileAsString As String

'XBM files are just raw C code, so they don't validate normally. Instead, I treat the file as a string
' and attempt to find key consts (declaring reasonable image dimensions).
Friend Function IsFileXBM(ByRef srcFilename As String, Optional ByVal requireValidFileExtension As Boolean = True) As Boolean
Expand Down Expand Up @@ -228,6 +226,8 @@ Friend Function LoadXBM_FromFile(ByRef srcFile As String, ByRef dstImage As pdIm
Const FUNC_NAME As String = "LoadXBM_FromFile"
LoadXBM_FromFile = False

On Error GoTo BadXBMFile

'Validate the file
If Me.IsFileXBM(srcFile, False) Then

Expand Down
2 changes: 0 additions & 2 deletions Controls/pdLayerListInner.ctl
Expand Up @@ -563,8 +563,6 @@ Private Sub ShowLayerPopupMenu(ByVal srcX As Long, ByVal srcY As Long)

m_PopupMenu.Reset

Dim menuItemVisible As Boolean

'Construct the menu. (The current layout of this menu largely mimics Photoshop.)
With m_PopupMenu
.AddMenuItem g_Language.TranslateMessage("Show this layer"), "layer_show", 0, menuIsChecked:=PDImages.GetActiveImage.GetLayerByIndex(m_RightClickIndex, True).GetLayerVisibility()
Expand Down
2 changes: 0 additions & 2 deletions Modules/Plugin_AVIF.bas
Expand Up @@ -485,8 +485,6 @@ End Function
'Returns TRUE if PD successfully downloaded (and initialized) all required plugins
Public Function PromptForLibraryDownload_AVIF(Optional ByVal targetIsImportLib As Boolean = True) As Boolean

Const FUNC_NAME As String = "PromptForLibraryDownload_AVIF"

On Error GoTo BadDownload

'Only attempt download if the current Windows install is 64-bit
Expand Down
2 changes: 0 additions & 2 deletions Modules/Plugin_jxl.bas
Expand Up @@ -809,8 +809,6 @@ End Function
'Returns TRUE if PD successfully downloaded (and initialized) all required plugins.
Public Function PromptForLibraryDownload_JXL(Optional ByVal targetIsImportLib As Boolean = True) As Boolean

Const FUNC_NAME As String = "PromptForLibraryDownload_JXL"

On Error GoTo BadDownload

'Like most modern libraries, libjxl requires at least Win 7
Expand Down
2 changes: 1 addition & 1 deletion Modules/TextSupport.bas
Expand Up @@ -113,7 +113,7 @@ Public Function ConvertPageRangeToStack(ByRef srcRange As String, ByRef dstStack

'Internationalized list separators follow
'https://en.wikipedia.org/wiki/Comma#Languages_other_than_Western_European
If (InStr(1, processedRange, ChrW(&H3001&), vbBinaryCompare) <> 0) Then processedRange = Replace$(processedRange, ChrW(&H3001&), " ", 1, -1, vbBinaryCompare)
If (InStr(1, processedRange, ChrW$(&H3001&), vbBinaryCompare) <> 0) Then processedRange = Replace$(processedRange, ChrW$(&H3001&), " ", 1, -1, vbBinaryCompare)

'Ensure hyphens are separated by whitespace too
Const HYPHEN_CHAR As String = "-"
Expand Down
8 changes: 3 additions & 5 deletions Modules/Units.bas
Expand Up @@ -45,11 +45,6 @@ End Enum

'Used to query the OS to determine if metric or imperial units should be the default
Private Const LOCALE_USER_DEFAULT As Long = &H400&

'From MSDN:
' System of measurement. The maximum number of characters allowed for this string is two, including a terminating null character.
' This value is 0 if the metric system (Systéme International d'Units, or S.I.) is used, and 1 if the United States system is used.
Private Const LOCALE_IMEASURE As Long = 13&
Private Declare Function GetLocaleInfo Lib "kernel32" Alias "GetLocaleInfoW" (ByVal Locale As Long, ByVal LCType As Long, ByVal lpLCData As Long, ByVal cchData As Long) As Long

'Given a measurement in pixels, convert it to some other unit of measurement. Note that at least two parameters are required:
Expand Down Expand Up @@ -201,6 +196,9 @@ Public Function LocaleUsesMetric() As Boolean
Dim sBuffer As String, sRet As String
sBuffer = String$(4, 0)

'From MSDN:
' System of measurement. The maximum number of characters allowed for this string is two, including a terminating null character.
' This value is 0 if the metric system (Systéme International d'Units, or S.I.) is used, and 1 if the United States system is used.
Const LOCALE_IMEASURE As Long = &HD&
sRet = GetLocaleInfo(LOCALE_USER_DEFAULT, LOCALE_IMEASURE, StrPtr(sBuffer), Len(sBuffer))

Expand Down

0 comments on commit 60be812

Please sign in to comment.