[引用]该C#程序可将文本文件藏于位图中,也可导出之!

vs2010编写的程序在2003系统无法定位程序输入点DecodePointer于动态链接库kernel32.dll上解决方案 从国外的网站看到的,亲测可用; 下载链接 http://yunpan.cn/cA2tSzH9bq6FN  访问密码 b492 Encode Pointer Library, by LoRd_MuldeR ======================================================= This library was created to a 阅读详情
http://blog.youkuaiyun.com/yiruoyun/archive/2004/10/18/141514.aspx

//使用方法:
// BmpSafe.exe /file2bmp (input BMP) (input file to hide) [output file]
//BmpSafe.exe /bmp2file (data BMP) [output file]

using System;
using System.IO;
using System.Drawing;

public class Bitmap24Writer
{
 protected Bitmap bmp;
 protected int curX, curY, iRGB;
 protected uint bitsLeft, bitsTotal;
 protected byte r, g, b;

 public Bitmap24Writer(Bitmap bmp)
 {
  if (bmp.PixelFormat != System.Drawing.Imaging.PixelFormat.Format24bppRgb)
   throw new ArgumentException();
  // assign vars
  curX       = curY = iRGB = 0;
  this.bmp   = bmp;
  bitsLeft   = bitsTotal = (uint)bmp.Height * (uint)bmp.Width * 3;
 }

 public uint GetUnusedBitCount()
 {
  return bitsLeft;
 }

 public uint GetMaxBitStorageCount()
 {
  return bitsTotal;
 }

 public Bitmap GetBitmap()
 {
  return bmp;
 }

 public bool WriteByte(byte by)
 {
  if (bitsLeft < 8)
   return false;

  uint bits2Do = 8;

  for (; curX < bmp.Width; curX++)
  {
   if (curY >= bmp.Height)
    curY = 0;

   for (; curY < bmp.Height; curY++)
   {
    if (bits2Do == 0)
     return true;

    Color col = bmp.GetPixel(curX, curY);
    r = col.R;
    g = col.G;
    b = col.B;

    for ( ; ; )
    {
     byte curBit = (byte)(by & 1);

     switch( iRGB )
     {
      case 0:
       r = (byte)(r & 0xFE);
       r |= curBit;
       break;

      case 1:
       g = (byte)(g & 0xFE);
       g |= curBit;
       break;

      case 2:
       b = (byte)(b & 0xFE);
       b |= curBit;
       break;
     }
     --bits2Do;
     --bitsLeft;
     by >>= 1;
     bmp.SetPixel(curX, curY, Color.FromArgb(r, g, b));
     if (iRGB == 2)
     {
      iRGB = 0;
      break;
     }
     iRGB++;
     if (bits2Do == 0)
      return true;
    }
   }
  }
  return true;
 }
}

public class Bitmap24Reader
{
 protected Bitmap bmp;
 protected int curX, curY, iRGB;
 protected uint bitsLeft, bitsTotal;

 public Bitmap24Reader(Bitmap bmp)
 {
  if (bmp.PixelFormat != System.Drawing.Imaging.PixelFormat.Format24bppRgb)
   throw new ArgumentException();
  curX       = curY = iRGB = 0;
  this.bmp   = bmp;
  bitsLeft   = bitsTotal = (uint)bmp.Height * (uint)bmp.Width * 3;
 }

 public uint GetUnusedBitCount()
 {
  return bitsLeft;
 }

 public uint GetMaxBitStorageCount()
 {
  return bitsTotal;
 }

 public Bitmap GetBitmap()
 {
  return bmp;
 }

 public bool ReadByte(out byte by)
 {
  by = 0;

  if (bitsLeft < 8)
   return false;

  byte bit = 0;
  uint bits2Do = 8;
  for (; curX < bmp.Width; curX++)
  {
   if (curY >= bmp.Height)
    curY = 0;

   for (; curY < bmp.Height; curY++)
   {
    if (bits2Do == 0)
     return true;

    Color col = bmp.GetPixel(curX, curY);
    for ( ; ; )
    {
     switch( iRGB )
     {
      case 0:
       bit = (byte)(col.R & 1);
       break;

      case 1:
       bit = (byte)(col.G & 1);
       break;

      case 2:
       bit = (byte)(col.B & 1);
       break;
     }
     --bits2Do;
     --bitsLeft;
     by |= (byte)(bit << 7);
     if (bits2Do != 0)
      by >>= 1;
     if (iRGB == 2)
     {
      iRGB = 0;
      break;
     }
     iRGB++;
     if (bits2Do == 0)
      return true;
    }
   }
  }
  return true;
 }
}

public class BitmapWorks
{
 public static bool Data2Bmp(FileStream dataStream, FileStream bmpStream, string outFName, out string error)
 {
  error = "";

  Bitmap bmp;
  try
  {
   bmp = new Bitmap(bmpStream);
  }
  catch
  {
   error = "Are you sure the specified bitmap is a valid bitmap ?";
   return false;
  }
  if (bmp.PixelFormat != System.Drawing.Imaging.PixelFormat.Format24bppRgb)
  {
   error = "Please drop only 24bit bitmaps,thanks !";
   return false;
  }

  error += "-> Bitmap info: height=" + bmp.Height + " width=" + bmp.Width + ".../n";

  if (dataStream.Length == 0)
  {
   error = "Input data has a not supported size of 0 !";
   return false;
  }
  uint maxByteStorage = ((uint)bmp.Height * (uint)bmp.Width * 3) / 8;
  error += "-> Up to " + (maxByteStorage-4) + " bytes could be stored in this bitmap.../n";
  if (maxByteStorage < dataStream.Length + 4)
  {
   error = "Not enough pixel in target bitmap to hide the input data block !";
   return false;
  }

  Bitmap24Writer bmpWriter = new Bitmap24Writer(bmp);
  uint dataSize = (uint)dataStream.Length;
  try
  {
   for (uint u = 0; u < 4; u++)
   {
    bmpWriter.WriteByte( (byte)dataSize );
    dataSize >>= 8;
   }
   for (uint u = 0; u < dataStream.Length; u++)
    bmpWriter.WriteByte( (byte)dataStream.ReadByte() );
  }
  catch
  {
   error = "Error while modifing the bitmap's pixels !";
   return false;
  }

  double maxBitStorage = bmpWriter.GetMaxBitStorageCount();
  double spaceUsed = (100 * (maxBitStorage - bmpWriter.GetUnusedBitCount())) / maxBitStorage;
        error += "-> Space used: " + Convert.ToUInt32(spaceUsed) + "%.../n";

  try
  {
   if ( File.Exists( outFName ) )
    File.Delete( outFName );
   bmpWriter.GetBitmap().Save(outFName);
  }
  catch
  {
   error = "Couldn't save output to " + outFName + " !";
   return false;
  }

  error += "-> Output saved to: " + outFName + ".../n";

  return true;
 }

 public static bool Bmp2Data(FileStream bmpStream, string outFName, out string error)
 {
  error = "";

  Bitmap bmp;
  try
  {
   bmp = new Bitmap(bmpStream);
  }
  catch
  {
   error = "Are you sure the specified bitmap is a valid bitmap ?";
   return false;
  }

  Bitmap24Reader bmpReader;
  try
  {
   bmpReader = new Bitmap24Reader(bmp);
  }
  catch (ArgumentException)
  {
   error = "This isn't a 24bit bitmap !";
   return false;
  }

  FileStream outStream;
  try
  {
   outStream = File.Create( outFName );
  }
  catch
  {
   error = "Couldn't create output file: " + outFName + " !";
   return false;
  }
  uint dataSize = 0;
  byte outByte;
  try
  {
   for (uint u = 0; u < 4; u++)
   {
    if ( !bmpReader.ReadByte( out outByte ) )
     throw new Exception();
    dataSize |= (uint)( outByte << 8*3 );
    if (u != 3)
     dataSize >>= 8;
   }
   error += "-> Size of hidden data: " + dataSize + " bytes.../n";
   for (uint u = 0; u < dataSize; u++)
   {
    if ( !bmpReader.ReadByte( out outByte ) )
     throw new Exception();
    outStream.WriteByte( outByte );
   }
  }
  catch
  {
   error = "Exception caught while reading the hidden data !";
   return false;
  }
  finally
  {
   outStream.Close();
  }

  error += "-> Output saved to: " + outFName + ".../n";

  return true;
 }

}

class BmpSafe
{
 public static string cmdLine =
  "Command line:/n" +
  "    BmpSafe.exe /file2bmp (input BMP) (input file to hide) [output file]/n" +
  "    BmpSafe.exe /bmp2file (data BMP) [output file]";

 private static string serviceOne = "/file2bmp";
 private static string serviceTwo = "/bmp2file";

 [STAThread]
 static void Main(string[] args)
 {
  Console.WriteLine(
   "BmpSafe - hide files in 24bit bitmaps/n" +
   "          a little steganografie implementation/n" +
   "          by yoda/n" +
   "-------------------------------------------------------------------------------/n");

  string inFile = "", inBmp, outFile;
  bool bFile2Bmp;
  if (args.Length < 2)
  {
   Console.WriteLine("!! Invalid number of arguments :(");
   Console.WriteLine(cmdLine);
   return; // ERR
  }
  if ( String.Compare(args[0], serviceOne, true) == 0 )
   bFile2Bmp = true;
  else if ( String.Compare(args[0], serviceTwo, true) == 0)
   bFile2Bmp = false;
  else
  {
   Console.WriteLine("!! First parameters must be either /"/file2bmp/" or /"/bmp2file/" !");
   return;
  }

  inBmp = args[1];
  if (bFile2Bmp)
  {
   if (args.Length < 3)
   {
    Console.WriteLine("!! Invalid number of arguments :(");
    Console.WriteLine(cmdLine);
    return;
   }
   inFile = args[2];
   if (args.Length > 3)
    outFile = args[3];
   else
    outFile = "Secret.BMP";
  }
  else
  {
   if (args.Length > 2)
    outFile = args[2];
   else
    outFile = "Secret.bin";
  }
  
  Console.WriteLine("-> Processing input...");
  try
  {
   string err;
   bool ret;

   if (bFile2Bmp)
    ret = BitmapWorks.Data2Bmp(
     File.OpenRead(inFile),
     File.OpenRead(inBmp),
     outFile,
     out err );
   else
    ret = BitmapWorks.Bmp2Data(
     File.OpenRead(inBmp),
     outFile,
     out err);
   if (!ret)
   {
    Console.WriteLine("!! " + err);
    return;
   }
   else
    Console.Write( err );
  }
  catch(FileNotFoundException)
  {
   Console.WriteLine("!! At least one file could not be found :(");
   return;
  }
  catch
  {
   Console.WriteLine("!! An exception occurred :(");
   return;
  }

  Console.WriteLine("-> Job done...");

  return;
 }
}

探索 C# 位图(Bitmap)处理:从历史到实践的全面指南 介绍了 C# 中的位图处理,涵盖位图的历史、原理、常用方法及高级操作,帮助理解图像处理的核心概念与技巧。 阅读详情

相关推荐

C#并口热敏小票打印机打印位图

最近一直在研究并口小票打印机打印图片问题,这也是第一次和硬件打交道,不过还好,最终成功了。   这是DEMO的窗体:   下面是打印所需要调用的代码: class LptControl { private string LptStr = "lpt1"; public LptControl(string l_LPT_Str) {

蒋倩兰——蕙质兰心 2万+

该C#程序可将文本文件藏于位图中,也可导出之。

//使用方法:// BmpSafe.exe /file2bmp (input BMP) (input file to hide) [output file]//BmpSafe.exe /bmp2file (data BMP) [output file]using System;using System.IO;using System.Drawing;public class Bitmap24W

cacacy的专栏 999

使用Excel的VBA来读取和修改bmp位图像素数据

很明显,需要使用VBA代码了。 点击此处下载全部源程序 选择一个8位或者24位的bmp位图来打开。 上图是一个8位位图的像素数据。 上图是一个24位位图的像素数据,由于该24位位图会灰色的位图,所以,RGB的值是一样的。 【更多文章】 [译]在C# .NET2.0实现单实例应用程序[原]ManageApps:C#读取Windows系统中的已经安装的程序并

apk508 8232

BMP图形文件分析类(c#)

1using System;  2using JJBase.FILE;  3namespace JJBase.Image  4{  5    /**////   6    /// BMP 的摘要说明。  7    ///   8    public class BMP  9    { 10         11        public BMP() 12        { 13         

深度Java 4665

C#+MySQL操作Blob对象,实现位图存取

本节介绍使用C#操作MySQL数据库中的二进制大对象BLOB,实现了位图的存储和读取。 1.建立和MySQL的连接 private void btnConnect_Click(object sender, EventArgs e) { if (m_con != null) {

lintaoshen的专栏 1321

运放相位补偿的180°秘密:为什么你的电路在阶跃信号下会抽风?

本文深入探讨了运放电路在阶跃信号下产生振荡的根本原因——相位裕度不足,并揭示了相位补偿技术的核心秘密。通过分析稳态与瞬态响应的差异,结合反馈电路设计中的实际案例,详细讲解了滞后补偿、超前补偿等方法的原理与应用,帮助工程师精准解决电路“抽风”问题,确保系统动态稳定性。

xxx12的博客 643

Visual Studio2011安装问题(更新无法定位程序输入点_Atomic_fetch_sub_4动态链接库MSVCR110.dll上的问题)

1、The Application Data folder for Visual Studio could not be created. 2、无法定位程序输入点_Atomic_fetch_sub_4动态链接库MSVCR110.dll上     以前一直都是直接在C盘下安装VS,没发生过什么问题,这次把VS11 Beta版装到D盘下,在运行时出现The Application Data f

sunny2038的专栏 1万+

KEIL 5.38如何手动安装ARM Compiler V5?完整配置流程分享

本文详细介绍了在KEIL 5.38环境下手动安装和配置ARM Compiler V5(AC5)的完整流程,解决历史遗留项目的兼容性问题。从获取安装包、环境变量设置到KEIL集成配置,逐步指导开发者完成AC5的部署,并提供了常见错误排查和性能优化建议,帮助开发者高效维护基于C编译器的老项目。

weixin_29168813的博客 629

C#程序可将文本文件藏于位图中,也可导出

//使用方法: // BmpSafe.exe /file2bmp (input BMP) (input file to hide) [output file] //BmpSafe.exe /bmp2file (data BMP) [output file] using System; using System.IO; using System.Drawing; public class Bitma

深度Java 3908

避坑指南:Zephyr RTOS与nRF Connect SDK环境搭建常见错误及解决方案

本文详细解析了Zephyr RTOS与nRF Connect SDK环境搭建过程中的常见错误及解决方案,涵盖网络问题、代理设置、SEGGER Embedded Studio配置、分支切换等关键环节。针对开发者实际遇到的痛点问题,提供了一系列实用技巧和深度排错方法,帮助高效完成NCS开发环境部署。

weixin_28685287的博客 172

金桔智慧物流之容器(托盘、周转箱等)定位及周转方案原理

金桔智慧物流之容器(托盘、周转箱等)定位及周转方案原理 在物流行业种,托盘是标准化运输的关键的配件,而容器存在丢失、盘点、闲置等管理问题。如何通过信息化的手段提升容器的寿命,提高调配效率,降低闲置是物流容器行业的关键点。 金桔蓝牙网关配合金桔蓝牙资产管理终端可以解决物流行业痛点问题。 容器管理面临的问题: 技术方案 场景描述之库房 场景描述之车辆 场景描述之终端 方案优势 ...

jinjufocus的博客 1184

该C#程序可将文本文件藏于位图中,也可导出之

//使用方法:// BmpSafe.exe /file2bmp (input BMP) (input file to hide) [output file]//BmpSafe.exe /bmp2file (data BMP) [output file]using System;using System.IO;using System.Drawing;public class Bitmap24W

肄若芸(yiruoyun)的专栏 2057

macOS向日葵闪退终极修复:权限设置与后台运行全解析

本文详细解析了macOS上向日葵远程控制软件闪退问题的根源与解决方案,重点介绍了权限设置与后台运行的优化方法。通过配置屏幕录制、辅助功能等关键权限,以及优化后台进程管理,有效解决闪退问题,提升远程控制软件的稳定性与使用体验。

fern8的博客 1772

C#结合JS解决Word添加无效位图导致进程停滞的问题

本文将介绍解决使用WordApp.Selection.InlineShapes.AddPicture方法时,添加无效的位图文件导致的服务器端 WORD 进程停滞,页面无响应的问题。

初九之潜龙勿用 4327

Python 爬虫实战:全球渔业船舶捕捞记录数据采集与分析全攻略

通过本项目,我们实现了对全球渔业船舶捕捞记录数据的采集、处理和可视化,为渔业资源管理和海洋生态保护提供了数据支持。未来,可以进一步结合机器学习和深度学习技术,对捕捞行为进行预测和分类,提高对非法捕捞活动的识别能力。

2201_76125261的博客 558

AUTOSAR 3万字面试题全面解析(持续更新)

ECU抽象层(EAL)是AUTOSAR架构中的一部分,它位于微控制器抽象层(MCAL)之下,但通常与MCAL一起被提及。EAL的目标是提供一个统一的接口来访问和管理ECU(Electronic Control Unit,电子控制单元)的硬件资源,包括处理器、存储器和外围设备。通过这种抽象,EAL使得上层软件能够以一种标准化的方式与ECU硬件交互,而不需要关心具体的硬件实现细节。EAL解决了硬件异构性带来的问题,即不同ECU可能采用不同类型的处理器和硬件配置。

大模型大数据攻城狮的专栏 5613

C# WinForm实现画笔签名及解决MemoryBmp格式问题

​我的文章 《C# 结合JavaScript实现手写板签名并上传到服务器》主要介绍了 web 版的需求实现,本文应项目需求介绍如何通过 C# WinForm 通过画布画笔实现手写签名,并在开发过程中解决遇到的一些格式转换的问题,提供一些思路。

初九之潜龙勿用 5218

蓝牙模块HM-10手册

蓝牙模块HM-10手册,该手册对蓝牙模块HM-10进行了详细的介绍和使用方法以及一些AT指令。

C++与C#创建位图,是否需要区分RGB和BGR模式

C++与C#创建位图,是否需要区分RGB和BGR模式

wangnaisheng的专栏 1208

大中型超市收银系统(可直接运行)

光步前台收银系统系统功能:商品销售、商品退货、挂单、收银员权限、会员销售、单品取消、整单取消、商品查询、脱机销售、脱机数据上传,基本资料下载,开钱箱、小票打印、收款结算,支持多币种付款方式(现金、储值卡、礼券、微信等),支持多种促销。运行环境:.net 4.0登陆信息用户名:1001 密码:123456内置商品信息,商品编码可输入00001000 - 00010000,测试效果相关功能键F5 结算 F9挂单 F11商品查询 F8退货 Insert单品取消 Del整单取消 F12开钱箱F2 会员 Ctrl+Z退出系统 Home 锁屏 相关源码待公开

jdk-8u144-linux-x64.tar.gz.

该资源为搭建Linux系统Java环境用,资源的后缀为tar.gz格式的压缩包

上一篇: [引用]dotNET下面调用Access中存储过程的方法
下一篇: [引用]C#钩子本线程内消息拦截
xdev
博客等级 码龄25年 1粉丝 33原创
评论
成就一亿技术人!
拼手气红包6.0元
还能输入1000个字符
 
 条评论被折叠 查看
添加红包

请填写红包祝福语或标题

个

红包个数最小为10个

元

红包金额最低5元

当前余额3.43元 前往充值 >
需支付:10.00元
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付元
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值