嗨,这里是我的代码:
procedure TForm4.Button1Click(Sender: TObject);
var
png: TPNGImage;
data: PRGBQarray;
p: ^tagRGBQuad;
i, o: integer;
begin
png := TPNGImage.Create;
try
png.LoadFromFile('C:\Untitled.png');
for o := 1 to 100 do
begin
data:=png.Scanline[o];
for I := 1 to 400 do
begin
p := @data^[i];
p.rgbGreen := p.rgbBlue;
p.rgbRed := p.rgbGreen;
end;
end;
img.picture.Assign(png);
finally
png.Free;
end;
end;
Run Code Online (Sandbox Code Playgroud)
它不起作用,它使pic杂乱,我确定这是因为rgbReserved.我该怎么办?
我一直在网上看几个小时,使用谷歌,尝试使用PDF,仍然无法在Delphi 7中加载图像资源.
我的test.rc文件是这样的:
1 RT_BITMAP "1.bmp"
Run Code Online (Sandbox Code Playgroud)
我已经添加了test.rc文件使用我的项目项目- >添加到项目..它编制了test.res在构建文件,并似乎已经自动包含在.RES文件到我的项目(因为使用{$ R test.res}会说我已经使用了那个资源).我也试图消除test.res利用项目工程- >从项目中删除..和手动添加{$ R test.res}我的项目.
但无论我如何包含test.res文件..我得到了
项目Project2.exe引发异常类EAccessViolation,并在模块'Project2.exe'中显示消息'地址00408D0C处的访问冲突'.读取地址00000001'.流程停止了.使用"步骤"或"运行"继续.
我首先使用了
Image1.Picture.Bitmap.LoadFromResourceID(hInstance,1);
Run Code Online (Sandbox Code Playgroud)
因为这是我用谷歌发现的.我收到了这个错误.后来我试过了
procedure TForm1.Image1Click(Sender: TObject);
var bBitmap : TBitmap;
begin
bBitmap := TBitmap.Create;
try
bBitmap.Handle := LoadBitmap(hInstance, '1');
Image1.Width := bBitmap.Width;
Image1.Height := bBitmap.Height;
Image1.Canvas.Draw(0,0,bBitmap);
finally
bBitmap.Free;
end;
end;
Run Code Online (Sandbox Code Playgroud)
这没有给我带来任何错误,也没有显示图像所以问题仍未解决.
我是使用资源的新手,但我必须在发布项目之前将一些图像加载到资源中,以便.BMP文件不会被调整...
任何帮助将非常感谢!
您好我想知道这是什么rgbReserved的RGBQuadArray,当我改变为什么RGB颜色有该图像上显示一些丑陋的线条?它与rgbReserved?有关吗?
我试图从一个尚未显示的视图创建一个位图,将其设置为Android中的OpenGL纹理.问题是,当我创建我的位图时,我的View的布局参数有0值,因为尚未调用onLayout()函数.有没有办法"模拟"布局或做一个"背景布局"来获得正确的布局参数?我正在考虑具有两个视图的Frame布局,背景一个用于创建我的位图,因为布局已经完成.
谢谢.
我写了函数:
public static byte[, ,] Bitmap2Byte(Bitmap image)
{
int h = image.Height;
int w = image.Width;
byte[, ,] result= new byte[w, h, 3];
for (int i = 0; i < w; i++)
{
for (int j = 0; j < h; j++)
{
Color c= image.GetPixel(i, j);
result[i, j, 0] = c.R;
result[i, j, 1] = c.G;
result[i, j, 2] = c.B;
}
}
return result;
}
Run Code Online (Sandbox Code Playgroud)
但转换1800x1800图像需要将近6秒钟.我能更快地做到吗?
编辑:
好的,我发现了这个:http://msdn.microsoft.com/en-us/library/system.drawing.imaging.bitmapdata.aspx
有很好的例子.我唯一的问题是Marshal.Copy.我可以将数据直接复制到byte[,,]?
编辑2:
好的,有时我得到奇怪的像素值,它们似乎没有遵循r0 …
我需要处理和保存原始bpp中的图像(1 - 对于BnW,8 - 对于灰色,24 - 颜色).处理后我总是有24bpp(由于使用Aforge.Net处理).我将原始bpp传递给保存功能,我正在使用下一个代码进行保存:
private static Bitmap changePixelFormat(Bitmap input, PixelFormat format)
{
Bitmap retval = new Bitmap(input.Width, input.Height, format);
retval.SetResolution(input.HorizontalResolution, input.VerticalResolution);
Graphics g = Graphics.FromImage(retval);
g.DrawImage(input, 0, 0);
g.Dispose();
return retval;
}
Run Code Online (Sandbox Code Playgroud)
当我通过时:
PixelFormat.Format8bppIndexed
Run Code Online (Sandbox Code Playgroud)
我得到一个例外:"图形对象无法在索引像素格式中创建图像":
Graphics g = Graphics.FromImage(retval);
Run Code Online (Sandbox Code Playgroud)
我已经尝试了下一个代码:
Bitmap s = new Bitmap("gray.jpg");
Bitmap NewPicture = s.Clone(new Rectangle(0, 0, s.Width, s.Height), PixelFormat.Format8bppIndexed);
Run Code Online (Sandbox Code Playgroud)
在此"NewImage"之后有PixelFormat 8bppIndexed,但是当我保存NewImage时:
NewPicture.Save("hello.jpg", ImageFormat.Jpeg);
Run Code Online (Sandbox Code Playgroud)
hello.jpg有24bpp.
我需要保留原始图像的bpp和图像格式.
为什么Bitmap.Save会忽略Bitmap的PixelFormat?
================================================== =====
谢谢大家,我找到了一个解决方案:http: //freeimage.sourceforge.net/license.html
借助这个免费库,可以将图像(尤其是JPEG)保存到8位灰度级.
我想绘制位图,手动指定的它的每一个点的颜色(换言之,任务是RGB值的2D阵列保存到PNG(或一些其它无损真彩色位图格式)文件).
在给定坐标处的图像顶部打印一些文本(具有给定大小的给定字体)的功能也是很好的.
怎么实现这个?
我正在寻找一种简单,特别快的可能性,将存储在文本文件中的二进制矩阵(仅由0和1组成)转换为某种情节.黑白位图完全符合我的可视化目的.我尝试使用gnuplot,但我认为gnuplot第一次还不够,因为我有很多数据(至少几十个MiB)并且内存消耗和处理时间很糟糕.
在搜索解决方案时,我主要发现与存储二进制(数据格式)的矩阵相关的内容以及在例如gnuplot中读取二进制数据格式的可能性.
你知道吗,可以将文本矩阵转换为位图的任何程序的快?我甚至考虑编写一个小C程序,但由于我无法估计创建位图有多难,因为我从来没有完成图像处理之前使用现有工具会很好,如果可能.
谢谢!
我有一个应用程序拍摄相机照片并将SD卡保存为jpeg.我想用一个spherize过滤器扭曲图片.我可以将jpeg读取到位图,但是我发现的代码是失真扭曲了bufferedimage.据我所知,android中不支持javax.imageio但是有没有办法将jpeg作为bufferedimage读入内存?
谢谢垫.
/*
Copyright 2006 Jerry Huxtable
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions …Run Code Online (Sandbox Code Playgroud)