Back to index

wims  3.65+svn20090927
Public Member Functions | Package Attributes | Private Member Functions | Private Attributes | Static Private Attributes
rene.util.BMPFile Class Reference

This is a bitmap writer I have somewhere from the Internet. More...

Collaboration diagram for rene.util.BMPFile:
Collaboration graph
[legend]

List of all members.

Public Member Functions

 BMPFile (String parFilename, Image parImage, int parWidth, int parHeight)
void saveBitmap ()
void run ()

Package Attributes

String parFilename
Image parImage
int parWidth
int parHeight

Private Member Functions

void save (Image parImage, int parWidth, int parHeight)
boolean convertImage (Image parImage, int parWidth, int parHeight)
void writeBitmap ()
void writeBitmapFileHeader ()
void writeBitmapInfoHeader ()
byte[] intToWord (int parValue)
byte[] intToDWord (int parValue)

Private Attributes

byte bitmapFileHeader [] = new byte [14]
byte bfType [] = { (byte)'B', (byte)'M'}
int bfSize = 0
int bfReserved1 = 0
int bfReserved2 = 0
int bfOffBits = BITMAPFILEHEADER_SIZE + BITMAPINFOHEADER_SIZE
byte bitmapInfoHeader [] = new byte [40]
int biSize = BITMAPINFOHEADER_SIZE
int biWidth = 0
int biHeight = 0
int biPlanes = 1
int biBitCount = 24
int biCompression = 0
int biSizeImage = 0x030000
int biXPelsPerMeter = 0x0
int biYPelsPerMeter = 0x0
int biClrUsed = 0
int biClrImportant = 0
int linepad = 0
int bitmap []
FileOutputStream fo

Static Private Attributes

static final int BITMAPFILEHEADER_SIZE = 14
static final int BITMAPINFOHEADER_SIZE = 40

Detailed Description

This is a bitmap writer I have somewhere from the Internet.

I excuse with the author of this to have lost his name. If he/she reads this, please mail me for that information.

However, I had to fix this to make it work properly.

The saving can be done in a separate Thread, if needed.

Definition at line 18 of file BMPFile.java.


Constructor & Destructor Documentation

rene.util.BMPFile.BMPFile ( String  parFilename,
Image  parImage,
int  parWidth,
int  parHeight 
) [inline]

Definition at line 60 of file BMPFile.java.


Member Function Documentation

boolean rene.util.BMPFile.convertImage ( Image  parImage,
int  parWidth,
int  parHeight 
) [inline, private]

Definition at line 109 of file BMPFile.java.

       {
              bitmap = new int [parWidth * parHeight]; 

              PixelGrabber pg = new PixelGrabber (parImage, 0, 0, parWidth, parHeight,
                     bitmap, 0, parWidth); 
              
              try {
                     pg.grabPixels (); 
              }
              catch (InterruptedException e) {
                     e.printStackTrace (); 
                     return (false); 
              }
              
              linepad =  4 - ((parWidth * 3) % 4); 
              if (linepad==4) linepad=0; 
              biSizeImage = (parWidth * 3 +linepad) * parHeight; 
              bfSize = biSizeImage + BITMAPFILEHEADER_SIZE + BITMAPINFOHEADER_SIZE; 
              biWidth = parWidth; 
              biHeight = parHeight; 
              
              return (true); 
       }

Here is the caller graph for this function:

byte [] rene.util.BMPFile.intToDWord ( int  parValue) [inline, private]

Definition at line 237 of file BMPFile.java.

                                                 {
              
              byte retValue [] = new byte [4]; 
              
              retValue [0] = (byte) (parValue & 0x00FF); 
              retValue [1] = (byte) ((parValue >> 8) & 0x000000FF); 
              retValue [2] = (byte) ((parValue >> 16) & 0x000000FF); 
              retValue [3] = (byte) ((parValue >> 24) & 0x000000FF); 
              
              return (retValue); 
              
       }

Here is the caller graph for this function:

byte [] rene.util.BMPFile.intToWord ( int  parValue) [inline, private]

Definition at line 220 of file BMPFile.java.

                                                {
              
              byte retValue [] = new byte [2]; 
              
              retValue [0] = (byte) (parValue & 0x00FF); 
              retValue [1] = (byte) ((parValue >> 8) & 0x00FF); 
              
              return (retValue); 
              
       }

Here is the caller graph for this function:

void rene.util.BMPFile.run ( ) [inline]

Definition at line 72 of file BMPFile.java.

       {      try {
                            fo = new FileOutputStream (parFilename); 
                            save (parImage, parWidth, parHeight); 
                            fo.close (); 
                     }
                     catch (Exception saveEx) {
                            saveEx.printStackTrace (); 
                     }
       }

Here is the call graph for this function:

Here is the caller graph for this function:

void rene.util.BMPFile.save ( Image  parImage,
int  parWidth,
int  parHeight 
) [inline, private]

Definition at line 91 of file BMPFile.java.

                                                                       {
              
              try {
                     convertImage (parImage, parWidth, parHeight); 
                     writeBitmapFileHeader (); 
                     writeBitmapInfoHeader (); 
                     writeBitmap (); 
              }
              catch (Exception saveEx) {
                     saveEx.printStackTrace (); 
              }
       }

Here is the call graph for this function:

Here is the caller graph for this function:

void rene.util.BMPFile.saveBitmap ( ) [inline]

Definition at line 68 of file BMPFile.java.

       {      run(); 
       }

Here is the call graph for this function:

void rene.util.BMPFile.writeBitmap ( ) [inline, private]

Definition at line 141 of file BMPFile.java.

       {
              int i,j,k; 
              int value; 
              byte rgb [] = new byte [3]; 
              
              try
              {      for (i=biHeight-1; i>=0; i--)
                     {      for (j=0; j<biWidth; j++)
                            {
                                   value = bitmap [i*biWidth+j]; 
                                   rgb [0] = (byte) (value & 0x000000FF); 
                                   rgb [1] = (byte) ((value >> 8) & 0x000000FF); 
                                   rgb [2] = (byte) ((value >> 16) & 0x000000FF); 
                                   fo.write (rgb); 
                            }
                            for (k=0; k<linepad; k++) fo.write(0x00); 
                     }
              }
              catch (Exception wb) {
                     wb.printStackTrace (); 
              }
              
       }

Here is the caller graph for this function:

void rene.util.BMPFile.writeBitmapFileHeader ( ) [inline, private]

Definition at line 170 of file BMPFile.java.

                                             {
              
              try {
                     fo.write (bfType); 
                     fo.write (intToDWord (bfSize)); 
                     fo.write (intToWord (bfReserved1)); 
                     fo.write (intToWord (bfReserved2)); 
                     fo.write (intToDWord (bfOffBits)); 
                     
              }
              catch (Exception wbfh) {
                     wbfh.printStackTrace (); 
              }
              
       }

Here is the call graph for this function:

Here is the caller graph for this function:

void rene.util.BMPFile.writeBitmapInfoHeader ( ) [inline, private]

Definition at line 193 of file BMPFile.java.

                                             {
              
              try {
                     fo.write (intToDWord (biSize)); 
                     fo.write (intToDWord (biWidth)); 
                     fo.write (intToDWord (biHeight)); 
                     fo.write (intToWord (biPlanes)); 
                     fo.write (intToWord (biBitCount)); 
                     fo.write (intToDWord (biCompression)); 
                     fo.write (intToDWord (biSizeImage)); 
                     fo.write (intToDWord (biXPelsPerMeter)); 
                     fo.write (intToDWord (biYPelsPerMeter)); 
                     fo.write (intToDWord (biClrUsed)); 
                     fo.write (intToDWord (biClrImportant)); 
              }
              catch (Exception wbih) {
                     wbih.printStackTrace (); 
              }
              
       }

Here is the call graph for this function:

Here is the caller graph for this function:


Member Data Documentation

Definition at line 33 of file BMPFile.java.

int rene.util.BMPFile.bfReserved1 = 0 [private]

Definition at line 31 of file BMPFile.java.

int rene.util.BMPFile.bfReserved2 = 0 [private]

Definition at line 32 of file BMPFile.java.

int rene.util.BMPFile.bfSize = 0 [private]

Definition at line 30 of file BMPFile.java.

byte rene.util.BMPFile.bfType[] = { (byte)'B', (byte)'M'} [private]

Definition at line 29 of file BMPFile.java.

int rene.util.BMPFile.biBitCount = 24 [private]

Definition at line 41 of file BMPFile.java.

Definition at line 47 of file BMPFile.java.

int rene.util.BMPFile.biClrUsed = 0 [private]

Definition at line 46 of file BMPFile.java.

Definition at line 42 of file BMPFile.java.

int rene.util.BMPFile.biHeight = 0 [private]

Definition at line 39 of file BMPFile.java.

int rene.util.BMPFile.biPlanes = 1 [private]

Definition at line 40 of file BMPFile.java.

Definition at line 37 of file BMPFile.java.

int rene.util.BMPFile.biSizeImage = 0x030000 [private]

Definition at line 43 of file BMPFile.java.

int rene.util.BMPFile.bitmap[] [private]

Definition at line 51 of file BMPFile.java.

byte rene.util.BMPFile.bitmapFileHeader[] = new byte [14] [private]

Definition at line 28 of file BMPFile.java.

final int rene.util.BMPFile.BITMAPFILEHEADER_SIZE = 14 [static, private]

Definition at line 22 of file BMPFile.java.

byte rene.util.BMPFile.bitmapInfoHeader[] = new byte [40] [private]

Definition at line 36 of file BMPFile.java.

final int rene.util.BMPFile.BITMAPINFOHEADER_SIZE = 40 [static, private]

Definition at line 23 of file BMPFile.java.

int rene.util.BMPFile.biWidth = 0 [private]

Definition at line 38 of file BMPFile.java.

int rene.util.BMPFile.biXPelsPerMeter = 0x0 [private]

Definition at line 44 of file BMPFile.java.

int rene.util.BMPFile.biYPelsPerMeter = 0x0 [private]

Definition at line 45 of file BMPFile.java.

FileOutputStream rene.util.BMPFile.fo [private]

Definition at line 54 of file BMPFile.java.

int rene.util.BMPFile.linepad = 0 [private]

Definition at line 48 of file BMPFile.java.

Definition at line 56 of file BMPFile.java.

Definition at line 58 of file BMPFile.java.

Image rene.util.BMPFile.parImage [package]

Definition at line 57 of file BMPFile.java.

Definition at line 58 of file BMPFile.java.


The documentation for this class was generated from the following file: