Re: Byte swapping efficiently



On Mike D Sutton wrote:

[...]
Private Function FlipWordB(ByVal inWord As Integer) As Integer ' Endian swap
on Word
FlipWordB = ((inWord And &H7F) * &H100) Or (((inWord And &HFF00) \
&H100) And &HFF)
If (inWord And &H80) Then FlipWordB = FlipWordB Or &H8000
End Function
[...]
Looks like FlipWordE() in the IDE, and FlipWordB() or FlipWordG() compiled
are the ones to go for if performance is your goal.
Hope this helps,

It does indeed help - many thanks, Mike (again - we must stop meeting
like this) and thanks also to others who responded.

Plugged into the app (and noting the \ is a /), it does make a
noticeable difference, although not as much as I'd hoped. However,
it's shifted the bottleneck away from byte-swapping, which was the
hoped outcome - it's now the simple mechanics of processing 55MB of
data that's holding the app up, but performance is now acceptable.

Incidentally, I've changed the function to return a Single, since
that's the data type expected by the calling routine.

For what it's worth, this is USGS GTOPO30 global elevation data, which
is chunked into usable sections and rendered to BMP for use in a
map-based interface in another part of the app.
--
John Hatpin
.



Relevant Pages

  • Re: COMPARE 2 BMP files where one is offset
    ... Second Response to Mike Sutton ... This other app is one big dialog class and has a small invisible area on the ... Is there a api function that will tell me the dimensions ... >> compare even if i had the exact size. ...
    (microsoft.public.vb.winapi.graphics)
  • Re: Explorer crashes when I open a folder or view drives in my com
    ... I went to my computer and opened one of the drives. ... App: E:\WINDOWS\Explorer.EXE ... Mike on the south coast of the UK ... Explorer needs to re start message is displayed ...
    (microsoft.public.windowsxp.perform_maintain)
  • RE: Remoting Error (newbie)
    ... "Mike Smith" wrote: ... I've just started going through the Microsoft 'building distributed ... > applications' book and am running into an error on the very first sample app. ...
    (microsoft.public.dotnet.framework.remoting)
  • Re: Setting Default Value in Form Field
    ... did it render an html, ... "Mike Painter" wrote: ... What is the syntax? ... each record this app will not be user friendly. ...
    (microsoft.public.access.formscoding)
  • Re: Windows XP Pro Shutdown
    ... date drivers might cause an app to hang on closing. ... "Mike" wrote in message ...
    (microsoft.public.windowsxp.accessibility)

Loading