Example Code

A Bitmap Resize Algorithm

Products and Environment

This section reflects the products and operating system used to create the example.

To download NI software, including the products shown below, visit ni.com/downloads.

    Software

  • LabVIEW

    Operating System

  • Windows

    Programming Language

  • LabVIEW G

Code and Documents

Attachment

Description

A Bitmap Resize Algorithm

 

This article handles a simple algorithm to resize (enlarge or reduce) computer pictures.

http://www.davdata.nl/math/bmresize-old.html

How to Use

We regard the bitmaps as pieces of paper.
A pixel is given the dimension 1 * 1.
The destination bitmap dimensions are the dimensions of the source bitmap
divided by a factor f.
So, for each destination pixel, a corresponding area (f*f) on the source map may be drawn.
In most cases, this area will partially overlap the pixels in the source.

The color of a destination pixel is the (weighted) addition of the colors of
the pixels covered on the source map.
In the picture above, 4 pixels in the source contribute to the (marked) pixel
in the destination.
This contribution is proportional to the area covered.

Example code from the Example Code Exchange in the NI Community is licensed with the MIT license.