Press on the image to return to the main documentation page.
Written by Andrew Graham
This library contains a Jpeg object that can extract portions of large jpeg files without having to decode the entire picture into a bitmap. This enables parts of those pictures that would be impossible to load in their entirety to be displayed at full resolution.
This process can be slow because versions of Android before 2.2 interpreted the bytecodes of their programs at runtime. Versions 2.2 of Android and later have a Just In Time compiler that compiles the bytecodes to native code. This should provide a significant decrease in the processing time of this library. The CPUs used by Android devices are quickly increasing in their processing speed which again should give a processing speed advantage to the most recent devices.
This is the Jpeg object that can extract portions of large jpeg files without having to decode the entire picture into a bitmap so enabling parts of those pictures that would be impossible to load in their entirety to be displayed at full resolution.
As a side effect of the jpeg decoding this object also has the ability transform a bitmap to and from an array of Ints representing the ARGB values of each pixel of the bitmap assuming that the bitmaps are in ARGB_8888 format. BmpConfig can be used to check this. This is an 'Activity Object', it cannot be declared under Sub Process_Globals.
Progress(percent As Int) 'The percentage of decoding progress.
Returns True if the specified bitmap is a mutable bitmap.
Gets or sets an integer array containing the ARGB values of the pixels of a Bitmap. If the array is set then BmpcOonfig, BmpWidth and BmpHeight should also be set with appropriate values.
Gets or sets the assumed width of the image contained in the pixel array.
Returns a new Bitmap created from the data in the pixel array, BmpHeight, BmpWidth and BmpConfig. Assume
GetBmpPixel (xAsInt, yAsInt) AsInt
Gets or sets the pixel ARBG value of the specified pixel in the pixel array.
This library incorporates Jpeg decoder code published under the GNU General Public License version 2. http://www.gnu.org/licenses/old-licenses/gpl-2.0.html The JPeg decoder in this library is based on C++ code for a Viewer ("JViewer") written and published by Bee-Chung Chen. http://www.cs.wisc.edu/~beechung/home/coding/index.html. Converted to Java by Helmut Dersch - email@example.com. Further modified for use with Basic4Android by Andrew Graham.
JpegHeightAsInt [read only]
Returns the height of the original jpeg image loaded by LoadSection or LoadSizeOnly.
JpegWidthAsInt [read only]
Returns the width of the original jpeg image loaded by LoadSection or LoadSizeOnly.
Loads the specified area of the image from instream setting JpegWidth, JpegHeight and allocating the BmpPixels array that contains the pixel data for that area also setting BmpConfig, BmpWidth and BmpHeight. Returns a new ARGB_8888 Bitmap created from the pixel data.
This method reads only as far along the file as it needs to to locate the required area so the position of the required area in the image affects the processing time of this method. Generally the lower down the image the bottom of the required area is located then the longer it takes. The size of the required area also has a major impact on the time taken as the calculation of each pixes value from the compressed data in the file requires a significant amount of processing.
Loads only the size of the image from instream setting JpegWidth and JpegHeight. The image itself is not loaded.
Loads a scaled version of the image from instream setting JpgWidth and JpegHeight The scaling is always an integer fraction of the original size, a denominator of 2 will give a half size image, 3 a denominator of three a third size image and so on. BmpConfig, BmpWidth, BmpHeight and the BmpPixels array are not affected by this method. Returns a new ARGB_8888 Bitmap which may be further scaled by Canvas.DrawBitmap if required.
There is a bug in Android that returns the values of an ARBG_8888 bitmap in ABGR order. This method swaps the R and B components of each value in the pixel array. Use this if you are not manipulating the colour values of each pixel yourself.
ProgressAsInt [read only]
Returns the percentage of progress during the execution of LoadJpegSection. This is the same value passed to the Progress event. That event is thread-safe and will always run on the main thread
SetBmpPixel (xAsInt, yAsInt, argbAsInt)
Sets the pixel array with the pixel values of the Bitmap provided. A new pixel array is allocated to hold the values. There is a bug in Android that returns the values of an ARBG_8888 bitmap in ABGR order. Use PixelsABGRtoARGB to fix this if you are not manipulating each pixel yourself.