{"id":23127927,"url":"https://github.com/zengming00/node-gd-bmp","last_synced_at":"2025-04-07T17:08:30.569Z","repository":{"id":17196907,"uuid":"81332191","full_name":"zengming00/node-gd-bmp","owner":"zengming00","description":"轻量、高速，完全由js实现的bmp图形模块，支持win/linux","archived":false,"fork":false,"pushed_at":"2023-03-05T14:51:42.000Z","size":1450,"stargazers_count":182,"open_issues_count":8,"forks_count":33,"subscribers_count":9,"default_branch":"master","last_synced_at":"2025-03-31T16:21:31.647Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":"","language":"TypeScript","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/zengming00.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2017-02-08T13:22:28.000Z","updated_at":"2024-10-30T23:56:59.000Z","dependencies_parsed_at":"2024-06-18T19:45:50.616Z","dependency_job_id":"9eb1dd0a-580c-4edd-b495-5f6d26014ade","html_url":"https://github.com/zengming00/node-gd-bmp","commit_stats":{"total_commits":14,"total_committers":2,"mean_commits":7.0,"dds":0.4285714285714286,"last_synced_commit":"12e57cf2325032a26a83a3aa7201a6b1553f47be"},"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/zengming00%2Fnode-gd-bmp","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/zengming00%2Fnode-gd-bmp/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/zengming00%2Fnode-gd-bmp/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/zengming00%2Fnode-gd-bmp/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/zengming00","download_url":"https://codeload.github.com/zengming00/node-gd-bmp/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":247694876,"owners_count":20980733,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":[],"created_at":"2024-12-17T09:15:44.768Z","updated_at":"2025-04-07T17:08:30.540Z","avatar_url":"https://github.com/zengming00.png","language":"TypeScript","funding_links":[],"categories":[],"sub_categories":[],"readme":"\u003ca href=\"https://996.icu\"\u003e\u003cimg src=\"https://img.shields.io/badge/link-996.icu-red.svg\" alt=\"996.icu\" /\u003e\u003c/a\u003e\n\n\n# node-gd-bmp\nlight and high speed and 100% js implement graphical library, it can running in any platform,\nBUT only support bmp 24bit format, internal contains 3 fonts\n# demo\n\n请看 src/demo，里面有关于如何做验证码、如何做图像处理的案例\n\n# API\n**获得对象的两种方式：**\n* 构造函数，创建指定宽高的图片对象(初始化为一张全黑的图片)\n```javascript\nimport { BMP24 } from 'gd-bmp';\nconst BMP24 = require('gd-bmp').BMP24;\nconst img = new BMP24(w, h);\n```\n* 从文件加载bmp (注意！必需确保文件是24位bmp)\n```javascript\nconst img = await BMP24.loadFromFile(file);\n```\n\n**获取BMP文件数据**\n```js\nobj.getFileData()\n```\n\n**Data Url**\n```js\nconst img = makeImg();\nconst dataUrl = img.getDataUrl();\nres.setHeader('Content-Type', 'text/html');\nres.end(`\u003cimg src=\"${dataUrl}\"/\u003e`);\n```\n\n**API**\n```js\n// 画点, RGB颜色值（例如红色0xff0000）\nobj.drawPoint(x, y, rgb)\n\n// 画点, rgb:{ blue:number, green:number, red:number }， 注意颜色值要保证在0-255之间（包含0和255）\nobj.drawPointRGB(x, y, rgb)\n\n// 获取像素点颜色, 返回 rgb: { blue:number, green:number, red:number } ，如果xy坐标超出图片范围将抛出错误\nobj.getPointRGB(x, y)\n\n// 画线\nobj.drawLine(x1, y1, x2, y2, rgb)\n\n// 画矩形\nobj.drawRect(x, y, w, h, rgb)\n\n// 实心矩形\nobj.fillRect(x, y, w, h, rgb)\n\n// 画圆\nobj.drawCircle(x, y, r, rgb)\n\n//画字符\u0026字符串，font参数为字库，color为RGB颜色值（例如红色0xff0000）\nobj.drawChar(ch, x, y, font, color)\nobj.drawString(str, x, y, font, color)\n```\n\n# 关于字体和颜色\n已经内置了三种规格的字体（仅包含大小写英文字母和数字），可以通过：BMP24.font8x16、BMP24.font12x24和BMP24.font16x32得到\n\n另外你也可以参考demo自己生成和定义字体\n\ndemo内包含一个支持中文的字库文件，支持65535个字符，需要占用2M内存\n\n颜色采用数值的方式，按RGB排列，例如：红色0xff0000，绿色0x00ff00，蓝色0x0000ff\n\n# 只支持24位bmp\n\n推荐用windows自带的画图工具转码bmp\n\n# License\nMIT\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fzengming00%2Fnode-gd-bmp","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fzengming00%2Fnode-gd-bmp","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fzengming00%2Fnode-gd-bmp/lists"}