這個用了好多次了,在blog上記錄一下吧
int SavePng(const string &png_file_name, byte **data, int width, int height, int bit_depth, png_colorp palette, int palette_len) { png_structp png_ptr; png_infop info_ptr; FILE *png_file = fopen(png_file_name.c_str(), "wb"); assert(png_file); png_ptr = png_create_write_struct(PNG_LIBPNG_VER_STRING, NULL, NULL, NULL); if(png_ptr == NULL) { cerr<<"ERROR:png_create_write_struct/n"; return 0; } info_ptr = png_create_info_struct(png_ptr); if(info_ptr == NULL) { cerr<<"ERROR:png_create_info_struct/n"; png_destroy_write_struct(&png_ptr, NULL); return 0; } png_init_io(png_ptr, png_file); png_set_IHDR(png_ptr, info_ptr, width, height, bit_depth, PNG_COLOR_TYPE_PALETTE, PNG_INTERLACE_NONE, PNG_COMPRESSION_TYPE_BASE, PNG_FILTER_TYPE_BASE); png_set_PLTE(png_ptr, info_ptr, palette, palette_len); png_write_info(png_ptr, info_ptr); //這裏就是圖像數據了 png_bytepp row_pointers = new png_bytep[height]; for (int i=0; i<height; ++i) { row_pointers[i] = (png_bytep)data[i]; } png_write_image(png_ptr, row_pointers); delete row_pointers; png_write_end(png_ptr, info_ptr); png_free(png_ptr, palette); palette=NULL; png_destroy_write_struct(&png_ptr, &info_ptr); fclose(png_file); return 0; } void ReadPng(const string &png_file, byte *buf, byte real_bit_dep) { FILE *file = fopen(png_file.c_str(), "rb"); assert(file); // create read struct png_structp png_ptr = png_create_read_struct(PNG_LIBPNG_VER_STRING, NULL, NULL, NULL); assert(png_ptr); // create info struct png_infop info_ptr = png_create_info_struct(png_ptr); assert(info_ptr); // I/O initialization using standard C streams png_init_io(png_ptr, file); // read entire image , ignore alpha channel png_read_png(png_ptr, info_ptr, PNG_TRANSFORM_IDENTITY|PNG_TRANSFORM_STRIP_ALPHA, NULL); int width = info_ptr->width; int height = info_ptr->height; int color_type = info_ptr->color_type; int bit_dep = info_ptr->pixel_depth; //這裏要注意任何小於8bpp的圖像被ps打開後都會被默認保存成8bpp的格式 if (bit_dep < 8) { png_destroy_read_struct(&png_ptr, &info_ptr, 0); fclose(file); return; } uint line_bytes = (uint)(width*bit_dep/8.0); printf("%d %d %d line_bytes=%d/n", width, height, bit_dep, line_bytes); //read pic data png_bytep* row_pointers = png_get_rows(png_ptr,info_ptr); uint real_line_bytes = (uint)(width*real_bit_dep/8.0); byte* real_ptr = new byte[real_line_bytes]; //write data to buf uint buf_offset = 0; printf("real_bit_dep = %d/n", real_bit_dep); for (int i=0; i<height; ++i) { //2bpp的情況 if (real_bit_dep == 2) { for (uint j=0, t=0; j<real_line_bytes; ++j, t+=4) { real_ptr[j] = ((row_pointers[i][t+3]&0x3)<<6) | ((row_pointers[i][t+2]&0x3)<<4) | ((row_pointers[i][t+1]&0x3)<<2) | (row_pointers[i][t]&0x3); } } //4bpp的情況 else if (real_bit_dep == 4) { for (uint j=0, t=0; j<real_line_bytes; ++j, t+=2) real_ptr[j] = ((row_pointers[i][t+1]&0xF) << 4) | (row_pointers[i][t]&0xF); } memcpy(&buf[buf_offset], real_ptr, real_line_bytes); buf_offset += real_line_bytes; } // free memory png_destroy_read_struct(&png_ptr, &info_ptr, 0); // close file fclose(file); }
本文分享自華爲雲社區《突破語言golang中的類型限制》,作者:碼樂。 1 簡介 在使用c語言編程時,常常因爲類型的問題大傷腦筋,而其他語言比如java,python默認類型又是難以改變的,golang提供了一些方式用於喜歡hack的用戶
本文分享自華爲雲社區《CWE 4.14 與 ISA/IEC 62443》,作者:Uncle_Tom。 1. 序言 隨着 5G 的應用,物聯的網發展,越來越多的自動化控制系統、雲服務在工業控制系統被廣泛使用。爲了實現生產自動化,很多企業都引
一、首先我們得清楚ARP是什麼東西? ARP通常就是我們認爲的ARP協議,也就是地址轉換協議,工作在OSI模型的數據鏈路層,用來把IP地址轉換爲MAC地址的,而RARP與ARP相反,是反向地址轉換協議,把MAC地址轉換爲IP地址。
one、概念 SQL注入(SQL Injection)就是攻擊者將SQL語句通過Web網頁注入到網站後臺的數據庫中,從而對數據庫進行控制或者破壞。SQL注入是一種主流的攻擊方式。在OWASP Top 10中,一直穩居第一。 two
【前言】 現在的路由器大多都默認用 WPA2-PSK 方式對無線網絡進行加密了,不能再像 WEP 加密方式那樣好破解,使用字典又需要費心費力地整理字典,而且字典破解的效率還慢。所以我們需要更有效率的破解方法。好在現在大多數的路由器
文章來源於信安旅途 Tips 文章最下方有小禮品噢~ 看完文章先嘛~ 0x01 Web漏洞掃描器 國內: 綠盟(W
document.cookie ="SESSDATA=49d4147c%2C8957247677%2Cf295e641;domain=.bilibili.com;path=/"; 在一個沒有保存b站cooki信息的網站上訪問b站,然後f
前言 分享一些使用burp中自己常用的技巧,覺得實用的話記得分享一下哦~ 1.快速生成CSRF測試代碼 測試csrf漏洞時候,快速生成scrf的html的代碼。 2.自動挖xss 在請求頭中自動加入xss
1. Kali Linux Kali Linux是最著名的Linux發行版,用於道德黑客和滲透測試。Kali Linux由Offensive Security開發,之前由BackTrack開發。 Kali Linux基於Debian。它
入侵Windows XP系統常用招數在這裏講述下黑客入侵Windows XP操作系統常用的七種方法,如果大家遇到類似那可要注意了…… 第一招:屏幕保護 在Windows中啓用了屏幕保護之後,只要我們離開計算機(或者不操作計算機)的時
轉自互聯網 不出所料~高端嫺熟的技術的SE在這次DQ5上果然使用了新的反燒錄技術~比較牛×的是這次更是連模擬器IDEAS都成功封殺掉了~俺這兩天由於沒日沒夜的趕課程設計~所以第一時間沒有去研究ROM~直到昨天終於浩浩蕩蕩的寫完了700
大概1年前些過程序生成字庫的程序,今天又要用到了,結果找了半天找不到,只好再重新寫一遍了,這個就是當時參考的教程,很不錯的。 顯示: 1BPP_VB 1BPP_VC 4BPP_VB 4BPP_VC 寫入 1BPP_VB 4BPP_
搜素引擎實際上就是一個爬取url的爬蟲 搜素引擎就是幫助我們獲取信息 對方的個人資料 公司信息 學校簡介 數據文件 … 谷歌語法: 關鍵字 功能 “” 雙引號內的內容不可拆分 site 指定域名 inur
信息收集對於滲透測試前期來說是非常重要,對於目標站點較爲安全的時候我們往往選擇尋找子域名進行滲透測試 子域名的形式: zkaq.org 頂級域名(一級) a.zkaq.org 二級域名 b.a.zkaq.org 三級域名