- html - 出于某种原因,IE8 对我的 Sass 文件中继承的 html5 CSS 不友好?
- JMeter 在响应断言中使用 span 标签的问题
- html - 在 :hover and :active? 上具有不同效果的 CSS 动画
- html - 相对于居中的 html 内容固定的 CSS 重复背景?
我刚刚开始学习计算机科学,我们的老师给了我们这个小但棘手的编程作业。我需要解码 .bmp 图像 http://postimg.org/image/vgtcka251/我们的老师交给了我们经过 4 个小时的研究和尝试,我还没有更接近解码它。他给了我们他的编码方法:
import java.io.FileInputStream;
import java.io.FileOutputStream;
import java.io.IOException;
public class HideMsgInPicture {
final static long HEADSIZE=120;
public static void main(String[] args) throws IOException {
encode();
decode();
}
private static void encode() throws IOException {
FileInputStream in = null;
FileInputStream msg = null;
FileOutputStream out = null;
try {
in = new FileInputStream("car.bmp");
msg = new FileInputStream("msg.txt");
out = new FileOutputStream("carX.bmp");
int c,mb;
byte clearBit1 = (byte) 0xFE; //254; // 11111110
for (int i=1;i<=HEADSIZE;i++) out.write(in.read()); //copy header
while ((mb = msg.read()) != -1) { // for all byte in message
for (int bit=7; bit>=0; bit--) // 1 bit a time from messsage
{ c = in.read() & clearBit1; // get picturebyte,clear last bit
c = (c | ((mb >> bit) & 1));// put msg-bit in end of pic-byte
out.write(c); // add pic-byte in new file
}
}
for (int bit=7; bit>=0; bit--) // add 8 zeroes as stop-byte of msg
{ c = in.read() & clearBit1; // get picturebyte,clear last bit
out.write(c); // add pic-byte in new file
}
while ((c = in.read()) != -1) out.write(c);// copy rest of file
}
finally {
if (in != null) in.close();
if (msg != null) msg.close();
if (out != null) out.close();
}
}
}
有人能引导我走向正确的方向吗?
最佳答案
您对隐写术了解多少?最简单的算法(即您的作业正在实现的算法)是最低有效位 (LSB)。简而言之,您将消息转换为二进制(即字符“a”= 01100001)并将各个位写入像素值的最右边位。例如,取 8 个像素(每个像素代表一个字节),第一个字节隐藏 0,第二个字节隐藏 1,第三个字节隐藏 1,第四个字节隐藏 0,等等。要提取消息,请从像素中的 LSB 并将其转换回文本。
你的老师给了你隐藏算法,所以基本上你必须编写一个反转该过程的算法。您不需要再看更多,您只需要了解这段代码的作用即可。只需内嵌注释就足够了。
关于java - 解码 .bmp 图像,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/16102362/
正如标题中所描述的那样。代码如下所示 #include #include using namespace std; #define WIDTH 90 #define HEIGHT 180 cla
我正在开发一个程序来调整 BMP 文件的大小并将其存储在一个新文件中。我注意到有些 BMP 完全颠倒存储,而其他 BMP 则只是直立存储。所以我做了两个解决方案来处理这两种情况。我的问题是如何事先知道
如何使用 ZPL II 打印位图 (BMP) 图像? 我使用 ~DY 将 BMP 下载到打印机: ~DYR:PRINT,B,B, , , 我正在使用 PHP 将原始数据发送到打印机,因此 <>
我正在尝试将彩色 BMP 文件转换为灰度 BMP。输入 bmp 是 24 位,我在输出端生成相同的 24 位 bmp,只是这次是灰度。 我使用的代码是 for(int x = 0; x < max;
正如在 this example 中所见, BMP 文件中的每个 channel (R, G, B) 接受一个输入。一个 24 位的 BMP 图像有 8 位的-R、8 位的 G 和 8 位的 B。我在
总结: 直接计算表明:一张3289 X 4570 X 32bpp的.BMP图片大约需要53MB。同样大小但24bpp的图片大约需要43MB,16bpp的图片大约需要28MB。在我的情况下,ChemDr
我有 24 位图像,我读取位图并将其转换为灰度并像 8 位一样保存。 RGBTRIPLE temp; unsigned char t; ... t = (temp.rgbtBlue * 0.114 +
我想从另一个更大的 bmp 文件中找到一个小的 bmp 文件(更大的一个是从屏幕上捕获的并称为 Sample.bmp ,小的 bmp 文件称为 Button.bmp 。事情是在比较图像时文件可以随处可
我需要使用 .bmp 类型的图像。其格式为: struct bmp_fileheader { unsigned char fileMarker1; /* 'B' */ unsigne
我正在尝试获取一个 BMP 文件并将其读入,然后对其中的像素执行操作以更改其颜色。我的问题是我无法将文件中的数据读入两个 BMP header 结构。我能够很好地将所有数据读入第一个结构,但在读入第二
这个问题已经有答案了: Why does comparing strings using either '==' or 'is' sometimes produce a different resul
我正在尝试使用以下代码将 bmp 图像转换为 jpeg。 from PIL import Image img = Image.open('/Desktop/xyz.bmp') new_img = im
在 24 位 bmp 中,像素存储为 BGR,每种颜色仅占用 1 个字节。那个可以读 for(i=0;i
我在学校有一个任务,要将水印 bmp 图像添加到其他 bmp 图像中。该任务称为 alpha 混合。我必须在用户将在启动时通过程序参数设置的特定坐标插入水印,以及水印混合的 alpha 值。我几乎成功
这是我的位图对象 Bitmap b = new Bitmap(columns, rows, PixelFormat.Format8bppIndexed); BitmapData bmd = b.Loc
我的编程平台是: Ubuntu 3.19 ImageMagick 6.7.7 编程语言:php 我的代码: $img = new Imagick($image_input_24bit_bmp); $i
这是我的函数,我根据维基百科 BITMAPINFOHEADER 使用标题 BMP。但是,我得到的文件没有任何图像...当放置填充时,该过程停止。 // Structures for header i
我正在发布一个 .NET 程序,并且正处于完善阶段。我需要在项目属性中设置图标。根据我的研究,我想创建以下像素大小的图像以适应所有图标大小:16、32、48、96、256。 我还找到了一个程序,可以将
我正在尝试从 BMP 图像创建 GD 图像资源,但是我没有运气。 有问题的 BMP 图像是用 Photoshop 创建和保存的。我也尝试了几个在网上找到的 BMP,它们给出了相同的结果。 getima
类型 FXPT2DOT30 出现在为 BMP 文件定义 struct CIEXYZ 时,根据微软提供的定义: http://msdn.microsoft.com/en-us/library/windo
我是一名优秀的程序员,十分优秀!