unidib

所属分类:Pascal/Delphi编程
开发工具:Delphi
文件大小:364KB
下载次数:2
上传日期:2007-12-03 19:14:00
上 传 者selami
说明:  (Delphi) Universal dib codes. Usign DIB palettes, dib bitmaps and more

文件列表:
24bit (0, 1998-12-29)
24bit\Proj24.dpr (263, 1998-07-05)
24bit\Proj24.exe (213504, 1998-10-14)
24bit\Unit24.dfm (434, 1998-07-03)
24bit\Unit24.pas (2441, 1998-10-14)
8bit (0, 1998-12-29)
8bit\Proj8.dpr (215, 1998-02-10)
8bit\Proj8.exe (213504, 1998-10-10)
8bit\Unit8.dfm (427, 1998-02-12)
8bit\Unit8.pas (1919, 1998-07-06)
DIBTools.pas (28569, 1998-09-12)
FileLoad (0, 1998-12-29)
FileLoad\FileLoad.dpr (252, 1998-07-27)
FileLoad\FileLoad.exe (231424, 1998-08-21)
FileLoad\Unit1.dfm (820, 1998-08-06)
FileLoad\Unit1.pas (2429, 1998-08-21)
UniDIB.pas (25062, 1998-08-26)

---------------------------------- * TUniDIB 1.26 * by Vit Kovalcik * ---------------------------------- released 4 Jan 1999 TUniDIB is class for working with Device Independent Bitmaps. There are many similar things on the internet, but one of them is for 16-bit color depth, other is for 256 colors only, no one is for more different BPP settings. So I decided to write own unit, which can work with all allowed bit depths (1,4,8,16,24 and 32). The result is TUniDIB. It was created on Delphi 2 and it should work with Deplhi 3. It is based on DIBSurfaceObject (by John Biddiscombe), TDIBSurface (by Agustin Villena) and TDIB16bit (from GMP; by ?). Big thanks to them. If you'll find it useful, please send me e-mail that you are using it. Welcomed are also messages about problems, errors etc. My e-mail address is : vkovalcik@iname.com WWW : http://www.geocities.com/SiliconValley/Hills/1335/ You can use this unit freely in your programs and modify it as well, but if you do so, please write my name in About Box or somewhere alike. WHAT'S NEW ---------- 1.26 (4 Jan 1999) - corrected UDIBLoadBMP 1.25 (24 Aug 19***) - corrected procedure DIBToScreen, now it also works when screen mode has 256 or 16 colors - corrected destructor Destroy - corrected TBufferedFile.PreReadBytes - corrected TBufferedFile.GetFilePos 1.21 (5 Aug 19***) - I am sorry but I forgot to put some files in the archive. Now it is corrected. 1.20 (27 Jul 19***) - added ability to load PCX and BMP files (see example) - optimized some routines 1.06 (6 Jul 19***) - added possibility to have upside down bitmap (pixel [0,0] is in upper left corner) 1.05 (5 Jul 19***) - added sequential access to pixels (about 30% faster) - added procedure CaptureScreen - changed procedure DrawHorizLine - changed examples to show advantage of sequential access - corrected procedure GetPixel16B - all code collected to one file 1.01 (24 Jun 19***) - initial release CONTENTS -------- Files in this archive: UniDIB.pas - main unit DIBTools.pas - additional functions readme.txt - this file 24bit\Proj24.dpr - example of using this unit in 24bit\Unit24.pas hi-color or true-color mode 24bit\Unit24.dfm (set constant C_BPP) 24bit\Proj24.exe 8bit\Proj8.dpr - example of using this unit in 8bit\Unit8.pas 256 color mode 8bit\Unit8.dfm 8bit\Proj.exe FileLoad\FileLoad.dpr - example of loading bitmaps FileLoad\Unit1.pas FileLoad\Unit1.dfm FileLoad\FileLoad.exe USING UNIT - READ CAREFULLY --------------------------- Using this unit is very easy, just include its name in uses clause and create class by it's contructor (Create). Specify width, height and number of bits per pixel (BPP). Normally is the pixel [0,0] in lower left corner, but if you want to have in the upper left one you must specify height with negative sign. There is another argument - SByteUse - That is only useful when setting DIB into 16 bits per pixel mode. While 16 bit mode uses actually 15 bits, it means the use of 16th bit in 2 bytes (=1 pixel). These constants are defined: SBU_NONE - 16th bit is unused SBU_RED - red element of pixel have 6 (SIX) bits; it is not visible, but it is more accurate for image conversions SBU_GREEN - same as above, but for green component SBU_BLUE - and for blue To set some pixel call SetPixel, but remember that point [0,0] is not upper left corner but the LOWER LEFT one! The "Value" specified in this procedure depends on BPP (specified in constructor) : BPP Value (Integer) - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - 1 0..1 - index of palette entry 4 0..15 - index of palette entry 8 0..256 - index of palette entry 16 1st byte = blue (only lower 5 bits are used) (AND $FF) 2nd byte = green (AND $FF00) 3rd byte = red (AND $FF0000) 24 same as 16 bits per pixel, but all bits in those three bytes are used 32 same as 24 bits per pixel. There is additional fourth byte in memory, which is not used, but only it is there. If you want to use 1,16 or 256 colors DIB, you must also specify the palette after the DIB is created. Simply call SetPalette with filled record TLogPalette256 (You don't need to set palVersion and palNumEntries). There are also another procedures - DrawLine, DrawVertLine, DrawHorizLine, FillPolygon, Clear and DIBToScreen. The last of them must be called to display the DIB. Argument can be for exaple : "Image1.Canvas.Handle". After that you should call Invalidate or another similar function or procedure. If you want to capture the whole screen, create DIB with desired width, height and bit depth and then call procedure CaptureScreen. In version 1.05 are several new procedures for writing/reading a row of pixels, which are about 30% faster than normal. Now you can call procedure Seek (X,Y) to set first pixel to write/read. After that just call procedure SetSeqPixel (Value) or function GetSeqPixel () to read/write one pixel and move pointer to next pixel in a row. DISCLAIMER ---------- The UniDIB unit is provided as is and without warranties or guaranties of any kind. Any loss or damage resulting from the use of the software is not the responsibility of the author. SUMMARY OF USABLE CONSTANTS, TYPES, PROCEDURES, FUNCTION AND PROPERTIES ----------------------------------------------------------------------- const SBU_NONE=0; SBU_RED=1; SBU_GREEN=2; SBU_BLUE=3; type PLogPalette256 = ^TLogPalette; TLogPalette256 = record palVersion: Word; palNumEntries: Word; palEntry: array[0..255] of TPaletteEntry; end; procedures & functions of class TUniDIB : constructor Create (AWidth,AHeight:LongInt;ABPP:Byte;SByteUse:Byte); destructor Destroy; procedure SetPixel (X,Y,Value:Integer); {It is variable, but it is like procedure} function GetPixel (X,Y:Integer):Integer; procedure SetSeqPixel (Value:Integer); function GetSeqPixel:Integer; procedure Seek (X,Y:Integer); procedure DIBtoScreen (DC:hDC); procedure SetPalette (Pal:TLogPalette256); procedure Clear; procedure DrawHorizLine (X1,X2,Y,Col:Integer); procedure DrawVertLine (X,Y1,Y2,Col:Integer); procedure DrawLine (X1,Y1,X2,Y2:integer; Col:Integer); procedure FillPolygon (Poly:Array of TPoint; FillCol:Integer); properties of class TUniDIB (all read-only) : property Width:LongInt; property Height:LongInt; property Handle:HBITMAP; property Bits:Pointer;

近期下载者

相关文件


收藏者