我有以下 C# 编码将上传的位图图像转换为十六进制。我需要按照算法在目标 C 中实现相同的目标。假设我有一个 UIImageView,其中包含从图片库中选择的图像。我需要将此选定的图像转换为十六进制并写入文本文件。
有人请帮我将此代码转换为Objective C。我对IOS开发有一些了解,但对图像处理了解不多。
这是我的代码,
Bitmap bm1 = (Bitmap)pictureBox1.Image;
int PictureWidth = pictureBox1.Image.Width;
int PictureHeight = pictureBox1.Image.Height;
int PictureX;
int PictureY;
int NVImageWidth;
int NVImageHeight;
NVImageWidth = PictureWidth;
NVImageHeight = PictureHeight;
int Quotient;
int Remainder;
int wp;
wp = 0;
StreamWriter sw = new StreamWriter("D:\\Test.txt");
for (PictureX = 0; PictureX <= PictureWidth - 1; PictureX++)
{
for (PictureY = 0; PictureY <= NVImageHeight - 1; PictureY++)
{
Color c1 = bm1.GetPixel(PictureX, PictureY);
if ((PictureY % 8) == 0)
{
wp = 0;
wp = (c1.G!=0) ? 0 : 1;
}
else if ((PictureY % 8) == 7)
{
wp = (wp << 1) | ((c1.G!=0) ? 0 : 1);
sw.Write(string.Format("%{0:x2}", wp));
}
else
{
wp = (wp << 1) | ((c1.G!=0) ? 0 : 1);
}
}
}
sw.Close();