图像文件格式BMP.docx

上传人:b****7 文档编号:9113483 上传时间:2023-02-03 格式:DOCX 页数:27 大小:61.10KB
下载 相关 举报
图像文件格式BMP.docx_第1页
第1页 / 共27页
图像文件格式BMP.docx_第2页
第2页 / 共27页
图像文件格式BMP.docx_第3页
第3页 / 共27页
图像文件格式BMP.docx_第4页
第4页 / 共27页
图像文件格式BMP.docx_第5页
第5页 / 共27页
点击查看更多>>
下载资源
资源描述

图像文件格式BMP.docx

《图像文件格式BMP.docx》由会员分享,可在线阅读,更多相关《图像文件格式BMP.docx(27页珍藏版)》请在冰豆网上搜索。

图像文件格式BMP.docx

图像文件格式BMP

 

课程名称专业英语

题目名称图像格式——BMP

学生学院机电工程学院

专业班级09数媒一班

学号3109000746

学生姓名李林钢

指导教师黄宪明

 

2013年1月12日

TheGraphicsFileFormat--BMP

TheBMPfileformat,alsoknownasbitmapimagefileordeviceindependentbitmap(DIB)fileformatorsimplyabitmap,isarastergraphicsimagefileformatusedtostorebitmapdigitalimages,independentlyofthedisplaydevice(suchasagraphicsadapter),especiallyonMicrosoftWindowsandOS/2operatingsystems.

TheBMPfileformatiscapableofstoring2Ddigitalimagesofarbitrarywidth,height,andresolution,bothmonochromeandcolor,invariouscolordepths,andoptionallywithdatacompression,alphachannels,andcolorprofiles.

Device-independentbitmapsandtheBMPfileformat

Microsofthasdefinedaparticularrepresentationofcolorbitmapsofdifferentcolordepths,asanaidtoexchangingbitmapsbetweendevicesandapplicationswithavarietyofinternalrepresentations.Theycalledthesedevice-independentbitmapsorDIBs,andthefileformatforthemiscalledDIBfileformatorBMPimagefileformat.AccordingtoMicrosoftsupport:

[1]

Adevice-independentbitmap(DIB)isaformatusedtodefinedevice-independentbitmapsinvariouscolorresolutions.ThemainpurposeofDIBsistoallowbitmapstobemovedfromonedevicetoanother(hence,thedevice-independentpartofthename).ADIBisanexternalformat,incontrasttoadevice-dependentbitmap,whichappearsinthesystemasabitmapobject(createdbyanapplication...).ADIBisnormallytransportedinmetafiles(usuallyusingtheStretchDIBits()function),BMPfiles,andtheClipboard(CF_DIBdataformat).

ThefollowingsectionsdiscussthedatastoredintheBMPfileorDIBindetail.ThisisthestandardBMPfileformat.[1]SomeapplicationscreatebitmapimagefileswhicharenotcompliantwiththecurrentMicrosoftdocumentation.Also,notallfieldsareused;avalueof0willbefoundintheseunusedfields.

Filestructure

Thebitmapimagefileconsistsoffixed-sizestructures(headers)aswellasvariable-sizestructuresappearinginapredeterminedsequence.Manydifferentversionsofsomeofthesestructurescanappearinthefile,duetothelongevolutionofthisfileformat.

Diag.1–Thestructureofthebitmapimagefile

Referringtothediagram1,thebitmapfileiscomposedofstructuresinthefollowingorder:

StructureName

Optional

Size

Purpose

Comments

BitmapFileHeader

No

14Bytes

TostoregeneralinformationabouttheBitmapImageFile

Notneededafterthefileisloadedinmemory

DIBHeader

No

Fixed-size

(however7differentversionsexist)

Tostoredetailedinformationaboutthebitmapimageanddefinethepixelformat

ImmediatelyfollowstheBitmapFileHeader

Extrabitmasks

Yes

3or4DWORDs[2]

(12or16Bytes)

Todefinethepixelformat

PresentonlyincasetheDIBHeaderistheBITMAPINFOHEADER

ColorTable

Semi-optional

Variable-size

Todefinecolorsusedbythebitmapimagedata(PixelArray)

Mandatoryforcolordepths<=8

Gap1

Yes

Variable-size

Structurealignment

AnartifactoftheFileOffsettoPixelArrayintheBitmapFileHeader

PixelArray

No

Variable-size

Todefinetheactualvaluesofthepixels

ThepixelformatisdefinedbytheDIBHeaderorExtrabitmasks.EachrowinthePixelArrayispaddedtoamultipleof4bytesinsize

Gap2

Yes

Variable-size

Structurealignment

AnartifactoftheICCProfileDataoffsetfieldintheDIBHeader

ICCColorProfile

Yes

Variable-size

Todefinethecolorprofileforcolormanagement

Canalsocontainapathtoanexternalfilecontainingthecolorprofile.Whenloadedinmemoryas"non-packedDIB",itislocatedbetweenthecolortableandgap1.[3]

DIBsinmemory

AbitmapimagefileloadedintomemorybecomesaDIBdatastructure–animportantcomponentoftheWindowsGDIAPI.Thein-memoryDIBdatastructureisalmostthesameastheBMPfileformat,butitdoesnotcontainthe14-bytebitmapfileheaderandbeginswiththeDIBheader.ForDIBsloadedinmemory,thecolortablecanalsoconsistof16bitentries,thatconstituteindexestothecurrentlyrealizedpalette[4](anadditionallevelofindirection),insteadofexplicitRGBcolordefinitions.Inallcases,thepixelarraymustbeginatamemoryaddressthatisamultipleof4bytes.Innon-packedDIBsloadedinmemory,theoptionalcolorprofiledatashouldbelocatedimmediatelyafterthecolortableandbeforethegap1andpixelarray[3](unlikeindiag.1).

Whenthesizeofgap1andgap2iszero,thein-memoryDIBdatastructureiscustomarilyreferredtoas"packedDIB"andcanbereferredtobyasinglepointerpointingtothebeginningoftheDIBheader.Inallcases,thepixelarraymustbeginatamemoryaddressthatisamultipleof4bytes.Insomecasesitmaybenecessarytoadjustthenumberofentriesinthecolortableinordertoforcethememoryaddressofthepixelarraytoamultipleof4bytes.[4]For"packedDIBs"loadedinmemory,theoptionalcolorprofiledatashouldimmediatelyfollowthepixelarray,asdepictedindiag.1(withgap1=0andgap2=0).[3]

"PackedDIBs"arerequiredbyWindowsclipboardAPIfunctionsaswellasbysomeWindowspatternedbrushandresourcefunctions.[5]

Bitmapfileheader

Thisblockofbytesisatthestartofthefileandisusedtoidentifythefile.AtypicalapplicationreadsthisblockfirsttoensurethatthefileisactuallyaBMPfileandthatitisnotdamaged.ThefirsttwobytesoftheBMPfileformatarethecharacter'B'thenthecharacter'M'in1-byteASCIIencoding.Alloftheintegervaluesarestoredinlittle-endianformat(i.e.least-significantbytefirst).

Offset#

Size

Purpose

0000h

2bytes

theheaderfieldusedtoidentifytheBMP&DIBfileis0x420x4Dinhexadecimal,sameasBMinASCII.Thefollowingentriesarepossible:

BM–Windows3.1x,95,NT,...etc.

BA–OS/2structBitmapArray

CI–OS/2structColorIcon

CP–OS/2constColorPointer

IC–OS/2structIcon

PT–OS/2Pointer

0002h

4bytes

thesizeoftheBMPfileinbytes

0006h

2bytes

reserved;actualvaluedependsontheapplicationthatcreatestheimage

0008h

2bytes

reserved;actualvaluedependsontheapplicationthatcreatestheimage

000Ah

4bytes

theoffset,i.e.startingaddress,ofthebytewherethebitmapimagedata(pixelarray)canbefound.

DIBheader(bitmapinformationheader)

Thisblockofbytestellstheapplicationdetailedinformationabouttheimage,whichwillbeusedtodisplaytheimageonthescreen.

TheblockalsomatchestheheaderusedinternallybyWindowsandOS/2andhasseveraldifferentvariants.Allofthemcontainadword(32bit)field,specifyingtheirsize,sothatanapplicationcaneasilydeterminewhichheaderisusedintheimage.

ThereasonthattherearedifferentheadersisthatMicrosoftextendedtheDIBformatseveraltimes.ThenewextendedheaderscanbeusedwithsomeGDIfunctionsinsteadoftheolderones,providingmorefunctionality.SincetheGDIsupportsafunctionforloadingbitmapfiles,typicalWindowsapplicationsusethatfunctionality.Oneconsequenceofthisisthatforsuchapplications,theBMPformatsthattheysupportmatchtheformatssupportedbytheWindowsversionbeingrun.Seethetablebelowformoreinformation.

Size

HeaderName

OSsupport

FeaturesAdded(incremental)

inBitmapFilesWrittenby

12

BITMAPCOREHEADER

OS21XBITMAPHEADER

OS/2andalsoallWindowsversionssinceWindows3.0

64

BITMAPCOREHEADER2

OS22XBITMAPHEADER

OS/2

Addshalftoning.AddsRLEandHuffman1Dcompression.

40

BITMAPINFOHEADER

allWindowsversionssinceWindows3.0

RemovesRLE-24andHuffman1Dcompression.Adds16bppand32bpppixelformats.AddsoptionalRGBbitmasks.

AdobePhotoshop

52

BITMAPV2INFOHEADER

Undocumented.

RemovesoptionalRGBbitmasks.AddsmandatoryRGBbitmasks.

56

BITMAPV3INFOHEADER

Undocumented.

Addsmandatoryalphachannelbitmask.

AdobePhotoshop

108

BITMAPV4HEADER

allWindowsversionssinceWindows95/NT4

Addscolorspacetypeandgammacorrection

124

BITMAPV5HEADER

Windows98/2000andnewer

AddsICCcolorprofiles

VersionsafterBITMAPCOREHEADERonlyaddfieldstotheendoftheheaderofthepreviousversion.Forexample:

BITMAPV2INFOHEADERaddsfieldstoBITMAPINFOHEADERandBITMAPV3INFOHEADERaddsfieldstoBITMAPV2INFOHEADER(or,BITMAPINFOHEADERisastrippedversionofBITMAPV2INFOHEADER)

Forcompatibilityreasons,mostapplicationsusetheolderDIBheadersforsavingfiles.WithOS/2beingobsolete,fornowthecommonformatistheBITMAPINFOHEADERheader.Seenexttableforitsdescription.Allvaluesarestoredasunsignedintegers,unlessexplicitlynoted.

Offset#

Size

Purpose

0Eh

4

thesizeofthisheader(40bytes)

12h

4

thebitmapwidthinpixels(signedinteger).

16h

4

thebitmapheightinpixels(signedinteger).

1Ah

2

thenumberofcolorplanesbeingused.Mustbesetto1.

1Ch

2

thenumberofbitsperpixel,whichisthecolordepthoftheimage.Typicalvaluesare1,4,8,16,24and32.

1Eh

4

thecompressionmethodbeingused.Seethenexttableforalistofpossiblevalues.

22h

4

theimagesize.Thisisthesizeoftherawbitmapdata(seebelow),andshouldnotbeconfusedwiththefilesize.

26h

4

thehorizontalresolutionoftheimage.(pixelpermeter,signedinteger)

2Ah

4

theverticalresolutionoftheimage.(pixelpermeter,signedinteger)

2Eh

4

thenumberofcolorsinthecolorpalette,or0todefaultto2n.

32h

4

thenumberofimportantcolorsused,or0wheneverycolorisimportant;generallyignored.

Note:

Theimagesizefieldcanbe0forBI_RGBbitmaps.

Thecompressionmethodfield(bytes#30-33)canhavethefollowingvalues:

Value

Identifiedby

Compr

展开阅读全文
相关资源
猜你喜欢
相关搜索

当前位置:首页 > 幼儿教育 > 育儿知识

copyright@ 2008-2022 冰豆网网站版权所有

经营许可证编号:鄂ICP备2022015515号-1