Android Programming Press on the image to return to the main documentation page.

Jpeg

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.

List of types:

Jpeg

Jpeg

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.

Events:

Progress(percent As Int) 'The percentage of decoding progress.

Members:


  BmpConfig As String

  BmpHeight As Int

  BmpIsMutable (bmp As android.graphics.Bitmap) As Boolean

  BmpPixels() As Int

  BmpWidth As Int

  GetBmpFromPixels As android.graphics.Bitmap

  GetBmpPixel (x As Int, y As Int) As Int

  Initialize (eventname As String)

  JpegHeight As Int [read only]

  JpegWidth As Int [read only]

  LoadJpegArea (instream As java.io.InputStream, left As Int, top As Int, width As Int, height As Int) As android.graphics.Bitmap

  LoadJpegSizeOnly (instream As java.io.InputStream)

  LoadJpegSmaller (instream As java.io.InputStream, denominator As Int) As android.graphics.Bitmap

  PixelsABGRtoARGB

  Progress As Int [read only]

  SetBmpPixel (x As Int, y As Int, argb As Int)

  SetPixelsFromBmp (bmp As android.graphics.Bitmap)

  Version As Double [read only]

Members description:

BmpConfig As String
Gets or sets the assumed config of the image contained in the pixel array.
The usual values of config will be either "RGB_565" or "ARGB_8888"
BmpHeight As Int
Gets or sets the assumed height of the image contained in the pixel array.
BmpIsMutable (bmp As android.graphics.Bitmap) As Boolean
Returns True if the specified bitmap is a mutable bitmap.
BmpPixels() As Int
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.
BmpWidth As Int
Gets or sets the assumed width of the image contained in the pixel array.
GetBmpFromPixels As android.graphics.Bitmap
Returns a new Bitmap created from the data in the pixel array, BmpHeight, BmpWidth and BmpConfig.
Assume
GetBmpPixel (x As Int, y As Int) As Int
Gets or sets the pixel ARBG value of the specified pixel in the pixel array.
Initialize (eventname As String)
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 - der@fh-furtwangen.de.
Further modified for use with Basic4Android by Andrew Graham.
JpegHeight As Int [read only]
Returns the height of the original jpeg image loaded by LoadSection or LoadSizeOnly.
JpegWidth As Int [read only]
Returns the width of the original jpeg image loaded by LoadSection or LoadSizeOnly.
LoadJpegArea (instream As java.io.InputStream, left As Int, top As Int, width As Int, height As Int) As android.graphics.Bitmap
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.
LoadJpegSizeOnly (instream As java.io.InputStream)
Loads only the size of the image from instream setting JpegWidth and JpegHeight.
The image itself is not loaded.
LoadJpegSmaller (instream As java.io.InputStream, denominator As Int) As android.graphics.Bitmap
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.
PixelsABGRtoARGB
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.
Progress As Int [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 (x As Int, y As Int, argb As Int)
SetPixelsFromBmp (bmp As android.graphics.Bitmap)
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.
Version As Double [read only]
Returns the version number of the library.
Top