home / infca / raw (navigation links) Foix : es quan dormo que hi veig clar.

Picss URLs | End

Imatges i formats


Vector graphics tools are critical to press-oriented publications. Unlike bitmap (or "raster") images, vector graphics are built for the precision print media tend to demand. Line art, extraneous design graphics, and body text for print copy all benefit from the scalability and accuracy vector graphics introduce to design work.

From "CorelDraw 9 for Linux: A vector graphics tool with punch. url

List of Linux Tools


RAW

Tinc 2 fotos de 262.144 bytes en Blanc i Negre. Jo els dic "RAW", cru, sense format : tenen 512 linies de 512 punts, cadascun de 1 byte, donant 256 nivells de gris.

Son :

La pregunta, ara, es : quin format te un fitxer JPG ? BMP ? On diu el tamany ? (ample x alt)
Feina : eina per passar JPG a RAW (512x512), passant segurament per BMP.
Eina : el SuperJPG por "Guardar" en format JPG, GIF, TIF, PNG i BMP.

Ratlles ! Mad ! Nuria ! Juan !

BMP

BMP !
A .BMP file contains of the following data structures:
 BITMAPFILEHEADER    bmfh ;             // File header (14 bytes)
 BITMAPINFOHEADER    bmih ;             // Info header (40 bytes)
 RGBQUAD             aColors [] ;       // called COLOR TABLE (not PALETTE).
 BYTE                aBitmapBits [] ;
BITMAPFILEHEADER structure is like this :
typedef struct tagBITMAPFILEHEADER {    // 14 bytes :
  WORD    bfType ;                      // 2 bytes : "BM"
  DWORD   bfSize ;                      // 4 bytes : file size in bytes
  WORD    bfReserved1 ;                 // 2
  WORD    bfReserved2 ;                 // 2
  DWORD   bfOffBits ;                   // 4 : file offset to raster data
} BITMAPFILEHEADER, * PBITMAPFILEHEADER ;

 
typedef struct { // 14 bytes : unsigned short int type ; /* (2) Magic identifier */ unsigned int size ; /* (4) File size in bytes */ unsigned short int reserved1, reserved2 ; // (2+2) unsigned int offset ; /* (4) Offset to image data, bytes */ } HEADER;
BITMAPINFOHEADER structure is like this :
InfoHeader might be : 12 bytes (OS/2 1.x), 40 bytes (Windows) or 64 bytes (OS/2 2.x) : URL or URL
typedef struct tagBITMAPINFOHEADER { // 40 bytes :
  DWORD   biSize ;                   // 4 - size of InfoHeader = 40
  LONG    biWidth ;                  // 4 - bitmap width
  LONG    biHeight ;                 // 4 - bitmap height
  WORD    biPlanes ;                 // 2 - number of planes (=1)
  WORD    biBitCount ;               // 2 - bits per pixel
                                     //    1 = monochrome      => NumColors = 1
                                     //    4 = 4bit palletized => NumColors = 16
                                     //    8 = 8bit palletized => NumColors = 256
                                     //   16 = 16bit RGB       => NumColors = 65536
                                     //   24 = 24bit RGB       => NumColors = 16M
  DWORD   biCompression ;            // 4 - type of compression
                                     //   0 = BI_RBG, no compression
                                     //   1 = BI_RLE8, 8bit RLE (run length) encoding
                                     //   2 = BI_RLE4, 4bit RLE encoding
                                     //   3 = RGB bitmap with mask
  DWORD   biSizeImage ;              // 4 - compressed size of image
                                     //     can be set to 0 if Compression = 0
  LONG    biXPelsPerMeter ;          // 4 - horizontal resolution : pixels/meter
  LONG    biYPelsPerMeter ;          // 4 - vertical resolution : pixels/meter
  DWORD   biClrUsed ;                // 4 - number of actually used colors
  DWORD   biClrImportant ;           // 4 - number of important colors (0 = all)
} BITMAPINFOHEADER, * PBITMAPINFOHEADER ;

 
typedef struct { // 40 bytes unsigned int size ; /* (4) Header size in bytes */ int width, height ; /* (4+4) Width and height of image */ unsigned short int planes ; /* (2) Number of colour planes */ unsigned short int bits ; /* (2) Bits per pixel */ unsigned int compression ; /* (4) Compression type */ unsigned int imagesize ; /* (4) Image size in bytes */ int xresolution, yresolution ; /* (4+4) Pixels per meter */ unsigned int ncolours ; /* (4) Number of colours */ unsigned int importantcolours ; /* (4) Important colours */ } INFOHEADER;
RGBQUAD structure is like this :
typedef struct tagRGBQUAD {
  BYTE    rgbBlue ;      { 1 - specifies the blue  part of the color }
  BYTE    rgbGreen ;     { 1 - specifies the green part of the color }
  BYTE    rgbRed ;       { 1 - specifies the red   part of the color }
  BYTE    rgbReserved ;  { 1 - must always be set to zero }
} RGBQUAD;
Present only if Info.BitsPerPixel <= 8. Colors should be ordered by importance.

Writing a bitmap to a BMP file is fairly simple if we have a handle to device-independent bitmap. We simply write BITMAPINFOHEADER information followed by the contents of the bitmap. The three fields that we have to set in the BITMAPINFOHEADER are the bfType which should always be "BM", the bfSize which is the size of the bitmap including the infoheader and the bfOffBits which is the offset to the bitmap bits from the start of the file.
If you have a device-dependent bitmap to begin with, you have to first create a DIB from it. Creating a DIB from a DDB has already been covered in another section.

// WriteDIB - Writes a DIB to file
// in :
//  szFile- Name of file to write to
//  hDIB- Handle of the DIB
// out :
//  Returns- TRUE on success

BOOL WriteDIB ( LPTSTR szFile, HANDLE hDIB ) {

 BITMAPFILEHEADER   hdr ;
 LPBITMAPINFOHEADER lpbi ;

     if ( ! hDIB )
          return FALSE ;

     CFile file ;
     if( ! file.Open ( szFile, CFile::modeWrite | CFile::modeCreate ) )
          return FALSE ;

     lpbi = (LPBITMAPINFOHEADER) hDIB ;

     int nColors = 1 << lpbi -> biBitCount ;

// Fill in the fields of the file header

     hdr.bfType = ((WORD) ('M' << 8) | 'B') ;      // is always "BM"
     hdr.bfSize = GlobalSize ( hDIB ) + sizeof( hdr ) ;
     hdr.bfReserved1 = 0 ;
     hdr.bfReserved2 = 0 ;
     hdr.bfOffBits = (DWORD) ( sizeof( hdr ) + lpbi -> biSize + nColors * sizeof( RGBQUAD ) ) ;

// Write the file header

     file.Write ( & hdr, sizeof ( hdr ) ) ;

// Write the DIB header and the bits

     file.Write ( lpbi, GlobalSize ( hDIB ) ) ;

     return TRUE ;
}

What made the BMP format successful was its support for indexing through 4 and 8-bit palettes. Rather than storing each of the necessary RGB values for each pixel, Microsoft instead added first a fixed and then a customisable palette to its BMP format. Each pixel's colour could then be defined by storing its associated index number rather than the much longer RGB value. This look-up table approach is inherently more efficient for handling images with up to 256 colours as each pixel can be stored in eight bits of information rather than twenty four. Microsoft was able to further optimise the BMP format by tying it even more closely to Windows' API, adding features such as control over which colours to dither when images are viewed on limited colour displays.

From here

See here or here or here (BITMAP.H, BITMAP.C, BMPVIEW.C)

Another important thing is that the number of bytes in one row must always be adjusted to fit into the border of a multiple of four. You simply append zero bytes until the number of bytes in a row reaches a multiple of four.

Pixels are stored bottom-up, left-to-right !

Collita propia

ParseBMP.c i EXE [T42:\miscosas\web\BMP\ReadBMP\]
Input : BMP filename.
Output :
  • lots of diagnostics
  • B/N RAW file (512x512)

Help :
WriteBMP.c i EXE [T42:\miscosas\web\BMP\WriteBMP\]
Input : 1 = Output BMP FileName. 2 = Work Index ("1" = 1/2 Black, 1/4 White, etc. "2" = read RAW from Param-3.)
Output :
  • B/N BMP file (786.486 bytes).

Help : WBMP (sin parámetro)
Ver_RAW (verrawp.exe) [T42:\Delphi\Foto\VerRAW\]
Input : RAW filename.
Output :
  • lots of diagnostics
  • Sys Info (pending to improve)

Help :
Work_RAW (workrawp.exe) [T42:\Delphi\Foto\WorkRAW\]
Input : RAW filename (512 linies de 512 bytes = 262.144 bytes)
Output :
  • lots of operations can be performed on the image (I mean lots of operations ...)

Help :
Book(s) : pending to find
COLOR_B [T42:\delphi\colors]
Input : none.
Output :
  • box of shading colors.

Help :
Code :
procedure TForm1.Pintar(Sender: TObject); const kAzul = $FF0000 ; kVerde = $00FF00 ; kRojo = $0000FF ; kBlanco = $FFFFFF ; kNegro = $000000 ; var a, b, c, x, y : integer ; begin for y := 1 to PaintBox1.Height do { vertical scan } for x := 1 to PaintBox1.Width do { horizontal scan } begin a := trunc ( y * (256/PaintBox1.Height) ) ; b := trunc ( x * (256/PaintBox1.Width) ) ; c := trunc ( ( a + b ) / 2 ) ; PaintBox1.Canvas.Pixels [ x, y ] := $000000 + ( c * $010101 ) ; { grey scale } PaintBox2.Canvas.Pixels [ x, y ] := $000000 + ( b * kRojo + a * kVerde ) ; { add } PaintBox3.Canvas.Pixels [ x, y ] := $FFFFFF - ( b * kRojo + a * kVerde ) ; { sub } end ; end;

Pictures

cd # 1 Fotos : 2002 & 2003 - DSC 00093 ... DSC 00828 cd # 2 Fotos : 2004 & 2005 - DSC 00829 ... DSC 01641 ... 709 files, 605 MB. P4:\G:\FotosAll\tot\ 080308 - DSC00084.JPG DSC03678.JPG 3341 archivos 2.818.107.646 bytes P4:\G:\Fotos2007\class\ 130308 3336 archivos T42:\D:\picsi\ 080308 - DSC00084.JPG DSC03678.JPG 3341 archivos 2.818.107.646 bytes IOMEGA:\fotos\ 080308 - DSC00084.JPG DSC03678.JPG 3341 archivos 2.818.107.646 bytes

Esther & Canon

{Juny 2011} Canon, EOS 1100D.

Fotos B/N ?


Amunt! Top Amunt!
Bons fotografs

Links


Ep ! Site under construction. Escriu-me !
Updated 20130115.  
Uf !