{"id":44,"date":"2008-01-28T18:11:54","date_gmt":"2008-01-28T22:11:54","guid":{"rendered":"http:\/\/jianmingli.com\/wp\/?p=44"},"modified":"2008-01-29T14:49:42","modified_gmt":"2008-01-29T18:49:42","slug":"dib","status":"publish","type":"post","link":"https:\/\/jianmingli.com\/wp\/?p=44","title":{"rendered":"DIB"},"content":{"rendered":"<p>Overview<\/p>\n<ul>\n<li>Device independent bitmap\n<ul>\n<li>Can be moved from device to device (hence device independent)<\/li>\n<\/ul>\n<\/li>\n<li>Normally transported in\n<ul>\n<li>metafiles<\/li>\n<li>bmp files<\/li>\n<li>clipboard (CF_DIB data format)<\/li>\n<\/ul>\n<\/li>\n<li>Contains\n<ul>\n<li>bits<\/li>\n<li>header\u00a0\n<ul>\n<li>describes the format of the bits\n<ul>\n<li>color format (color table)<\/li>\n<li>size of the bitmap<\/li>\n<\/ul>\n<\/li>\n<\/ul>\n<\/li>\n<\/ul>\n<\/li>\n<li>Supports\n<ul>\n<li>1-bit, 4-bit, 8-bit\n<ul>\n<li>pixels are defined by indexes into color table<\/li>\n<\/ul>\n<\/li>\n<li>24-bit\n<ul>\n<li>1 byte each for red, green, and blue<\/li>\n<\/ul>\n<\/li>\n<\/ul>\n<\/li>\n<li>DIB functions\n<ul>\n<li>GetDIBits<\/li>\n<li>SetDIBits<\/li>\n<li>CreateDIBBitmap<\/li>\n<li>SetDIBitsToDevice<\/li>\n<li>StretchDIBits<\/li>\n<li>CreateDIBPatternBrush<\/li>\n<\/ul>\n<\/li>\n<\/ul>\n<p>DIB Header<\/p>\n<ul>\n<li>Consists two adjoioning parts\n<ul>\n<li>header<\/li>\n<li>color table<\/li>\n<\/ul>\n<\/li>\n<li>Combined into the BITMAPINFO structure\n<ul>\n<li>biSize<\/li>\n<li>biWidth<\/li>\n<li>biHeight<\/li>\n<li>biPlanes\n<ul>\n<li>Should always be 1<\/li>\n<\/ul>\n<\/li>\n<li>biBitCount\n<ul>\n<li>Color resolution in bits per pixel.<\/li>\n<li>Allowed are 1, 4, 8, and 24<\/li>\n<\/ul>\n<\/li>\n<li>biCompression\n<ul>\n<li>Type of compression<\/li>\n<li>Can be\n<ul>\n<li>BI_RGB<\/li>\n<li>BI_RLE4<\/li>\n<li>BI_RLE8<\/li>\n<\/ul>\n<\/li>\n<\/ul>\n<\/li>\n<li>biSizeImage\n<ul>\n<li>Size of the bitmap proper in bytes<\/li>\n<\/ul>\n<\/li>\n<li>\u00a0biXPelsPerMeter<\/li>\n<li>biYPelsPerMeter<\/li>\n<li>biClrUsed<\/li>\n<li>biClrImportant\u00a0<\/li>\n<\/ul>\n<\/li>\n<\/ul>\n<p>OS2 Style DIB<\/p>\n<ul>\n<li>A DIB file has\n<ul>\n<li>A file header<br \/>\n<code lang=\"c\"><br \/>\n\/\/ 14 bytes since each WORD is 2 bytes and DWORD is 4<br \/>\ntypedef struct tagBITMAPFILEHEADER \/\/ bmfh<br \/>\n{<br \/>\n\u00a0 WORD bfType ; \/\/ signature word \"BM\" or 0x4D42<br \/>\n\u00a0 DWORD bfSize ; \/\/ entire size of file<br \/>\n\u00a0 WORD bfReserved1 ; \/\/ must be zero<br \/>\n\u00a0 WORD bfReserved2 ; \/\/ must be zero<br \/>\n\u00a0 DWORD bfOffsetBits ; \/\/ offset in file of DIB pixel bits<br \/>\n}<br \/>\nBITMAPFILEHEADER, * PBITMAPFILEHEADER ;<br \/>\n<\/code><\/li>\n<li>An information header<br \/>\n<code lang=\"c\"><br \/>\ntypedef struct tagBITMAPCOREHEADER \/\/ bmch<br \/>\n{<br \/>\n\u00a0 DWORD bcSize ; \/\/ size of the structure = 12<br \/>\n\u00a0 WORD bcWidth ; \/\/ width of image in pixels<br \/>\n\u00a0 WORD bcHeight ; \/\/ height of image in pixels<br \/>\n\u00a0 WORD bcPlanes ; \/\/ = 1<br \/>\n\u00a0 WORD bcBitCount ; \/\/ bits per pixel (1, 4, 8, or 24)<br \/>\n}<br \/>\nBITMAPCOREHEADER, * PBITMAPCOREHEADER ;\/\/ Also defined in WINGDI.H<br \/>\ntypedef struct tagBITMAPCOREINFO \/\/ bmci<br \/>\n{<br \/>\n\u00a0 BITMAPCOREHEADER bmciHeader ; \/\/ core-header structure<br \/>\n\u00a0 RGBTRIPLE bmciColors[1] ; \/\/ color table array<br \/>\n\/\/ Always 2, 16, or 256 RGBTRIPLE structures depending on bits per pixel<br \/>\n\/\/ Allocate PBITMAPCOREINFO for an 8-bit DIB<br \/>\n\/\/ pbmci = malloc (sizeof (BITMAPCOREINFO) + 255 * sizeof (RGBTRIPLE)) ;<br \/>\n}<br \/>\nBITMAPCOREINFO, * PBITMAPCOREINFO ;<\/code><\/li>\n<li>An RGB color table (but not always. not with 24 bit\/pixel DIB)\n<ul>\n<li>An array of 3 byte RGBTRIPLE structures<br \/>\n<code lang=\"c\"><br \/>\ntypedef struct tagRGBTRIPLE \/\/ rgbt<br \/>\n{<br \/>\n\u00a0 BYTE rgbtBlue ; \/\/ blue level<br \/>\n\u00a0 BYTE rgbtGreen ; \/\/ green level<br \/>\n\u00a0 BYTE rgbtRed ; \/\/ red level<br \/>\n}<br \/>\nRGBTRIPLE ;<br \/>\n<\/code><\/li>\n<\/ul>\n<\/li>\n<li>The bitmap pixel bits<\/li>\n<\/ul>\n<\/li>\n<li>A in\u00a0memory DIB has exactly as DIB file minus file\u00a0header<\/li>\n<\/ul>\n<p><a href=\"http:\/\/support.microsoft.com\/kb\/q81498\/\">http:\/\/support.microsoft.com\/kb\/q81498\/<\/a><\/p>\n","protected":false},"excerpt":{"rendered":"<p>Overview Device independent bitmap Can be moved from device to device (hence device independent) Normally transported in metafiles bmp files clipboard (CF_DIB data format) Contains bits header\u00a0 describes the format of the bits color format (color table) size of the &hellip; <a href=\"https:\/\/jianmingli.com\/wp\/?p=44\">Continue reading <span class=\"meta-nav\">&rarr;<\/span><\/a><\/p>\n","protected":false},"author":2,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"_exactmetrics_skip_tracking":false,"_exactmetrics_sitenote_active":false,"_exactmetrics_sitenote_note":"","_exactmetrics_sitenote_category":0,"jetpack_post_was_ever_published":false,"_jetpack_newsletter_access":"","_jetpack_dont_email_post_to_subs":false,"_jetpack_newsletter_tier_id":0,"_jetpack_memberships_contains_paywalled_content":false,"_jetpack_memberships_contains_paid_content":false,"footnotes":"","jetpack_publicize_message":"","jetpack_publicize_feature_enabled":true,"jetpack_social_post_already_shared":false,"jetpack_social_options":{"image_generator_settings":{"template":"highway","default_image_id":0,"font":"","enabled":false},"version":2}},"categories":[11,10],"tags":[],"class_list":["post-44","post","type-post","status-publish","format-standard","hentry","category-cpp","category-winos"],"jetpack_publicize_connections":[],"jetpack_featured_media_url":"","jetpack_sharing_enabled":true,"jetpack_shortlink":"https:\/\/wp.me\/s8cRUO-dib","_links":{"self":[{"href":"https:\/\/jianmingli.com\/wp\/index.php?rest_route=\/wp\/v2\/posts\/44","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/jianmingli.com\/wp\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/jianmingli.com\/wp\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/jianmingli.com\/wp\/index.php?rest_route=\/wp\/v2\/users\/2"}],"replies":[{"embeddable":true,"href":"https:\/\/jianmingli.com\/wp\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=44"}],"version-history":[{"count":0,"href":"https:\/\/jianmingli.com\/wp\/index.php?rest_route=\/wp\/v2\/posts\/44\/revisions"}],"wp:attachment":[{"href":"https:\/\/jianmingli.com\/wp\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=44"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/jianmingli.com\/wp\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=44"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/jianmingli.com\/wp\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=44"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}