Ä Area: F-QUICKBASIC ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ Msg#: 434 Date: 13 Apr 94 23:27:15 From: MIKE AUDLEMAN Read: Yes Replied: No To: GREG FROMMER Mark: Subj: BMP'S AND THERE WORKINGS ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ Subspace Message: FR: Greg Frommer TO: Mike Audleman Coded Subject: BMP'S AND THERE WORKINGS GF> Yes I would very much like to persue this.. If you have any coad I GF> would very much like to see some.. thank you GF> greg f Here is a real hack job I did a while back to seperate a bunch of BMP images into seperate color and B&W directories. It is called from a batch file using a "for %%x in (*.BMP)" type line. The code reads the header of the BMP and picks out the B&W ones and the color ones and then moves them to their directories. This file contains the TYPE statement for a BMP file header which is probably the thing that you should seperate from this file and save for your use. I use this same header TYPE statement in all my programs dealing with BMPs, both QB45 and VB. -------------->8-------------------------------------------------- DEFINT A-Z TYPE BitMapFileHeader '14 Bytes bfType AS STRING * 2 '&H4D42 or "BM" bfSize AS LONG 'Size of the file bfReserved1 AS INTEGER 'Not Used |Think these are used in bfReserved2 AS INTEGER '" " |OS\2 BMPs but not sure bfOffBits AS LONG 'addr of start of actual data biSize AS LONG '40 (The Size of the BI header) biWidth AS LONG 'Image Width biHeight AS LONG 'Image Height biPlanes AS INTEGER '# of planes, DIBs have only 1 biBitCount AS INTEGER 'bits per pixel (8 for 256 colors) biCompression AS LONG 'Compression type :BI_RGB = none biSizeImage AS LONG 'Image size (0 if Compression=BI_RGB biXPelsPerMeter AS LONG '0 biYPelsPerMeter AS LONG '0 biClrUsed AS LONG 'Number of colors actually used (Leave at 256) biClrImportant AS LONG 'Number of important colors (0 = all) biColorTable AS STRING * 64 'Color Table. Size changes END TYPE DIM SHARED Text AS STRING * 256, Byte AS STRING * 1, BMPHeader AS BitMapFileHeader 'Process the command line into file and path File$ = LTRIM$(COMMAND$) File$ = RTRIM$(File$) Spac% = INSTR(File$, " ") IF Spac% = 0 THEN File1$ = File$ ELSE File1$ = MID$(File$, Spac% + 1) File$ = LEFT$(File$, Spac% - 1) END IF Backs = INSTR(File1$, "\") Colon = INSTR(File1$, ":") Path$ = ".\" IF Backs > 0 THEN FOR X = LEN(File1$) TO Backs STEP -1 IF MID$(File1$, X, 1) = "\" THEN Where = X: EXIT FOR NEXT X Path$ = LEFT$(File1$, Where) File1$ = Path$ + MID$(File1$, Where + 1, 8) ELSEIF Colon > 0 THEN Path$ = LEFT$(File1$, Colon) File1$ = Path$ + MID$(File1$, Colon + 1, 8) ELSE File1$ = LEFT$(File1$, 8) END IF IF INSTR(File1$, ".") > 0 THEN File1$ = LEFT$(File1$, INSTR(File1$, ".") - 1) 'Ok, here we go with the main loop: OPEN File$ FOR BINARY AS 1 LEN = 8192 'Len 8192 makes it faster, not needed IF LOF(1) = 0 THEN CLOSE : PRINT "File Length=0": KILL File$: END GET 1, , BMPHeader 'Load the header of the file 'check for valid BMP file IF BMPHeader.bfType <> "BM" OR BMPHeader.bfReserved1 <> 0 OR BMPHeader.bfReserved2 <> 0 THEN CLOSE PRINT File$; " is not a recognized BMP type" END END IF CLOSE 'BitCount will be 1 for B&W SELECT CASE BMPHeader.biBitCount CASE 1 SHELL "Move " + File$ + " " + Path$ + "b&w" CASE ELSE SHELL "Move " + File$ + " " + Path$ + "color" END SELECT END FUNCTION GetByte% 'This simple function gets a single byte from file and converts to integer GET 1, , Byte$ GetByte% = ASC(Byte$) END FUNCTION -------------->8-------------------------------------------------- This section may be a bit long winded but it is vital you understand the entries in the file and image headers. The file header is distinguished by the variables starting with "bf" and the image header variables start with "bi". Print this out and use a hex file viewer and peek at some BMPs and compare values you find. That is how I learned what is in them and what they do. ---File Header area (Disk File oriented data) This is always "BM" for BMP and DIB files bfType AS STRING * 2 '&H4D42 or "BM" This should be set to the total file size including this header bfSize AS LONG 'Size of the file Set to 0 in every BMP I have. bfReserved1 AS INTEGER 'Not Used |Think these are used in bfReserved2 AS INTEGER '" " |OS\2 BMPs but not sure This is the start address relitive to the start of the file where the actual image data starts bfOffBits AS LONG 'addr of start of actual data ----Image Header area (Image oriented data) This is the size of the image header, always 40 biSize AS LONG '40 (The Size of the BI header) This is the size of the image (ex, 1024 & 768) biWidth AS LONG 'Image Width biHeight AS LONG 'Image Height Number of bit planes. BMP and DIB only have 1 biPlanes AS INTEGER '# of planes, DIBs have only 1 This is the number of bits needed to represent each pixel. This directly equates to the number of possible colors. 1 B&W (2 color) 4 for 16 colors 8 for 256 colors 24 for 24 bit true color biBitCount AS INTEGER 'bits per pixel (8 for 256 colors) This marks the file compression type. 0 for No compression (the most common) 1 for RLE8 (Run Length Encoding, 8 Bit) 2 for RLE4 ("" "" "" 4 bit) biCompression AS LONG 'Compression type :BI_RGB = none This is the data size. If Compression is 0 then this can be 0 too biSizeImage AS LONG 'Image size (0 if Compression=BI_RGB These specify the the pixels per meter that the BMP/DIB was designed for or the resolution if you will. biXPelsPerMeter AS LONG '0 biYPelsPerMeter AS LONG '0 This is the number of colors that are actually used in the color table. For example, you have a 256 color BMP that actually has only 12 colors then this value would be 12. This is mainly used by windows for palate managemet along with the next entry. Set to 0 to specify all colors. biClrUsed AS LONG 'Number of colors actually used (Leave at 256) This is the number of colors that are important in the color table. For example, you have a 256 color BMP that actually has only 12 colors and 5 of them were important to the image and the remaining were shading or whatever, then this value would be 5. This is mainly used by windows for palate managemet along with the previous entry. Set to 0 to specify all colors. biClrImportant AS LONG 'Number of important colors (0 = all) This is the color table or palate for the image. The size will vary with the number of colors specified by the biBitCount entry. Number of Colors: Size of Color table: 2 8 16 64 256 1024 2^24 0 (Not used for 24 bit true color) biColorTable AS STRING * 64 'Color Table. Size changes Later ... Mike Audleman ... Well I've confirmed it - cats can't swim. ___ Blue Wave/QWK v2.12 -!- ! Origin: Exec-PC BBS > World's Largest BBS < (1:154/280)