# The Wiert Corner – irregular stream of stuff

• ## Email Subscription

Enter your email address to subscribe to this blog and receive notifications of new posts by email.

Join 2,481 other followers

# Archive for May 13th, 2021

## How to calculate bitmap size? – Stack Overflow

Posted by jpluimers on 2021/05/13

A while ago I needed an estimate for [WayBack] How to calculate bitmap size? – Stack Overflow, which does an accurate calculation for the size of the pixel storage (i.e. without headers):

pixelStorageSize = (( width*bitsPerPixel + 31) / 32) * 4 * height

Here:

• 4 is the number of bytes per quad-byte as bitmaps are stored with pixel lines aligned on quad-byte boundaries
• 32 is the bits per quad-byte
• 31 helps to round up to the quad-word boundary

It was derived from [WayBack] Capturing an Image – Windows applications | Microsoft Docs and shorthand for what is explained at [WayBack] BMP file format: Pixel storage – Wikipedia

The bits representing the bitmap pixels are packed in rows. The size of each row is rounded up to a multiple of 4 bytes (a 32-bit DWORD) by padding.

For images with height above 1, multiple padded rows are stored consecutively, forming a Pixel Array.

The total number of bytes necessary to store one row of pixels can be calculated as:

{\displaystyle {\text{RowSize}}=\left\lceil {\frac {{\text{BitsPerPixel}}\cdot {\text{ImageWidth}}}{32}}\right\rceil \cdot 4=\left\lfloor {\frac {{\text{BitsPerPixel}}\cdot {\text{ImageWidth}}+31}{32}}\right\rfloor \cdot 4,}
ImageWidth is expressed in pixels, note the special parentheses.

The total amount of bytes necessary to store an array of pixels in an n bits per pixel (bpp) image, with 2ncolors, can be calculated by accounting for the effect of rounding up the size of each row to a multiple of 4 bytes, as follows:

PixelArraySize = RowSize · |ImageHeight|
ImageHeight is expressed in pixels. The absolute value is necessary because ImageHeight can be negative.

I think I needed this to estimate how many bitmaps would fit in

[WayBack] Virtual address space – Wikipedia, which on 32-bit Windows by default is limited to 2 GiB, and can be extended to 3 GIB by enabling the IMAGE_FILE_LARGE_ADDRESS_AWARE executable header flag.

This flag imposes the risk of many libraries and DLLs to fail because they do not get the pointer math right. You often do not have control of future versions of DLLs being loaded in your process space and their risks, so do not ever use that flag.

–jeroen

## Chocolatey: installing Oracle SQL Developer and updating the chocolatey package

Posted by jpluimers on 2021/05/13

Sometimes an install is not just as simple as C:\>choco install --yes oracle-sql-developer.

Edit 20210514:

Note that most of the below pain will be moot in the future as per [Archive.is] Jeff Smith 🍻 on Twitter: “we’re working on removing the SSO requirement, it’s already done for @oraclesqlcl – see here … “ referring to [Wayback] SQLcl now under the Oracle Free Use Terms and Conditions license | Oracle Database Insider Blog

SQLcl, the modern command-line interface for the Oracle Database, can now be downloaded directly from the web without any click-through license agreement.

It means the Oracle acount restriction will be lifted, and downloads will be a lot simpler.

I started with the below failing command, tried a lot of things, then finally almost gave up: Oracle stuff does not want to be automated, which means I should try to less of their stuff.

First of all you need an Oracle account (I dislike companies doing that for free product installs; I’m looking at Embarcadero too) by going to profile.oracle.com:

### Notes

• This version supports both 32bit and 64bit and subsequently does not have a JDK bundled with it. It has a
dependency on the jdk8 package to meet the application’s JDK requirement.
• An Oracle account is required to download this package. See the “Package Parameters” section below for
details on how to provide your Oracle credentials to the installer. If you don’t have an existing account, you can
create one for free here: https://profile.oracle.com/myprofile/account/create-account.jspx

### Package Parameters

The following package parameters are required:

/Username: – Oracle username
/Password: – Oracle password

(e.g. choco install oracle-sql-developer --params "'/Username:MyUsername /Password:MyPassword'")

To have choco remember parameters on upgrade, be sure to set choco feature enable -n=useRememberedArgumentsForUpgrades.

Then the installation failed fail again: ERROR: The response content cannot be parsed because the Internet Explorer engine is not available, or Internet Explorer's first-launch configuration is not complete. Specify the UseBasicParsing parameter and try again. 

The trick is to RUN IEXPLORE.EXE AS ADMINISTRATOR ONCE BEFORE INSTALLING FROM CHOCOLATEY. Who would believe that.

The reason is that the package uses Invoke-WebRequest which requires Internet Explorer and PowerShell 3. Chocolatey packages however need to be able to run on just PowerShell 2 without Invoke-WebRequest.

Maybe using cURL can remedy that; adding a dependency to is is possible, as cURL can be installed via chocolatey: [WayBack] How to Install cURL on Windows – I Don’t Know, Read The Manual. Another alternative might be [WayBack] Replace Invoke-RestMethod in PowerShell 2.0 to use [WayBack] WebRequest Class (System.Net) | Microsoft Docs.

## Notities over corona vaccinatie, gele vaccinatieboekje en vaccinatieboekje app

Posted by jpluimers on 2021/05/13

In het internationaal erkende gele vaccinatieboekje (ook wel vaccinatiepaspoort) kun je je corona vaccinatie laten bijschrijven. Dit kan ter plekke na de vaccinatie of op een later moment (maar op een later moment is het veel lastiger).

Het ministerie van Volksgezondheid Welzijn en Sport zegt in een reactie dat je als je wil, je een geel boekje kan gebruiken wanneer je wordt gevaccineerd. Maar dat het ze zelf geen boekjes aanbieden en dat er zéker geen verplichting is.

vaccinatieboekje: het internationale bewijs van inenting waar vaccinaties voor bijvoorbeeld gele koorts, dtp, hepatitis A en B in geregistreerd worden. Hier kan de coronavaccinatie (Covid-19) eenvoudig aan toegevoegd worden.

De [Wayback] Vaccinatieboekje app lijkt niet rechtsgeldig, maar wel handig voor reminders.

Registreer je (rijks) vaccinaties online en download de app: Vaccinatieboekje. Lees welke vaccinaties als je op reis gaat en leer meer over infectie-ziekten.

Gerelateerd:

Via:

jeroen

## Het hopelijk tijdelijke afscheid door Haagse Insider🕵🏻‍♂️ (@HaagseInsider) | Twitter

Posted by jpluimers on 2021/05/13

Gisteren was er een (hopelijk tijdelijk) afscheid door [Archive.is] Haagse Insider🕵🏻‍♂️ (@HaagseInsider) | Twitter.

Sowieso wens ik meer rust en afstand voor HaagseInsider. Daarnaast duim ik dat het een weerzien wordt.

jeroen

Posted in Power User, SocialMedia, Twitter | Leave a Comment »

## Delphi: EInvalidOp exception, might just mean you have a use-after free scenario, or an out-of-bounds value

Posted by jpluimers on 2021/05/13

Quite some time ago, I was researching spurious exceptions in a Delphi application, then finally replicated them in a unit test suite.

One of them was occurring almost all of the time: EInvalidOp.

It is one of the floating point exceptions (incidentally exampled at [WayBack] Exceptions: Declaring Exception Types) all inheriting from the [WayBack] EMathError Class:

EMathError is the base class for floating-point math exception classes. EMathError itself is never raised.

The following exceptions descend from EMathError:

[WayBack] Exception
Meaning
[WayBack] EInvalidArgument
Parameter out of range
[WayBack] EInvalidOp
Processor encountered an undefined instruction
[WayBack] EOverflow
Floating-point operation produced result too large to store
[WayBack] EUnderflow
Floating-point operation produced result with no precision
[WayBack] EZeroDivide
Attempt to divide by zero

Run-time exception information is saved in fields provided by [WayBack] EExternal.

### Use-after-free

In my first case (which I described in delphi – Invalid floating point operation calling Trunc()), not all input scenarios had been tested in a certain scenario. In a production environment, one of the inputs was really high.

In a later case, the actual cause was not a floating point problem at all, but a use-after-free scenario that overwrite a floating point value with something not so compatible also causing a simple Trunc statement to fail in the same way.

In that case, the production data could never reach the big numbers that failed, so no new tests were needed.

–jeroen