本文整理汇总了C#中System.Drawing.FastBitmap.LockImage方法的典型用法代码示例。如果您正苦于以下问题:C# FastBitmap.LockImage方法的具体用法?C# FastBitmap.LockImage怎么用?C# FastBitmap.LockImage使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类System.Drawing.FastBitmap
的用法示例。
在下文中一共展示了FastBitmap.LockImage方法的11个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: DrawImage
public Bitmap DrawImage(Color[] colors)
{
if (Width < 1 || Height < 1) {
return null;
}
var image = new Bitmap(Width, Height);
var fastBmp = new FastBitmap(image);
fastBmp.LockImage();
for (int y = 0, i = 0; y < Height; y++) {
for (var x = 0; x < Width; x++) {
fastBmp.SetPixel(x, y, colors[(int)Cells[i++].Type]);
}
}
fastBmp.UnlockImage();
return image;
}
示例2: DrawImage
public Bitmap DrawImage(Color[] Colors) {
if (Width < 1 || Height < 1) {
return null;
}
Bitmap Image = new Bitmap(Width, Height);
FastBitmap fastBmp = new FastBitmap(Image);
using (Graphics g = Graphics.FromImage(Image)) {
fastBmp.LockImage();
for (int y = 0, i = 0; y < Height; y++) {
for (int x = 0; x < Width; x++) {
fastBmp.SetPixel(x, y, Colors[(int)Cells[i++].Type]);
}
}
fastBmp.UnlockImage();
}
return Image;
}
示例3: DecodeImage
/// <summary>
/// Decode caption from the input stream
/// </summary>
/// <returns>bitmap of the decoded caption</returns>
public static Bitmap DecodeImage(PcsObject pcs, IList<OdsData> data, List<PaletteInfo> palettes)
{
if (pcs == null || data == null || data.Count == 0)
return new Bitmap(1, 1);
int w = data[0].Size.Width;
int h = data[0].Size.Height;
var bm = new FastBitmap(new Bitmap(w, h));
bm.LockImage();
BluRaySupPalette pal = DecodePalette(palettes);
int index = 0;
int ofs = 0;
int xpos = 0;
byte[] buf = data[0].Fragment.ImageBuffer;
index = 0;
do
{
int b = buf[index++] & 0xff;
if (b == 0 && index < buf.Length)
{
b = buf[index++] & 0xff;
if (b == 0)
{
// next line
ofs = (ofs / w) * w;
if (xpos < w)
ofs += w;
xpos = 0;
}
else
{
int size;
if ((b & 0xC0) == 0x40)
{
if (index < buf.Length)
{
// 00 4x xx -> xxx zeroes
size = ((b - 0x40) << 8) + (buf[index++] & 0xff);
Color c = Color.FromArgb(pal.GetArgb(0));
for (int i = 0; i < size; i++)
PutPixel(bm, ofs++, c);
xpos += size;
}
}
else if ((b & 0xC0) == 0x80)
{
if (index < buf.Length)
{
// 00 8x yy -> x times value y
size = (b - 0x80);
b = buf[index++] & 0xff;
Color c = Color.FromArgb(pal.GetArgb(b));
for (int i = 0; i < size; i++)
PutPixel(bm, ofs++, c);
xpos += size;
}
}
else if ((b & 0xC0) != 0)
{
if (index < buf.Length)
{
// 00 cx yy zz -> xyy times value z
size = ((b - 0xC0) << 8) + (buf[index++] & 0xff);
b = buf[index++] & 0xff;
Color c = Color.FromArgb(pal.GetArgb(b));
for (int i = 0; i < size; i++)
PutPixel(bm, ofs++, c);
xpos += size;
}
}
else
{
// 00 xx -> xx times 0
Color c = Color.FromArgb(pal.GetArgb(0));
for (int i = 0; i < b; i++)
PutPixel(bm, ofs++, c);
xpos += b;
}
}
}
else
{
PutPixel(bm, ofs++, b, pal);
xpos++;
}
} while (index < buf.Length);
bm.UnlockImage();
return bm.GetBitmap();
}
示例4: GenerateBitmap
private Bitmap GenerateBitmap(Rectangle imageDisplayArea, int imageTopFieldDataAddress, int imageBottomFieldDataAddress, List<Color> fourColors)
{
if (imageDisplayArea.Width <= 0 || imageDisplayArea.Height <= 0)
return new Bitmap(1, 1);
var bmp = new Bitmap(imageDisplayArea.Width + 1, imageDisplayArea.Height + 1);
if (fourColors[0] != Color.Transparent)
{
var gr = Graphics.FromImage(bmp);
gr.FillRectangle(new SolidBrush(fourColors[0]), new Rectangle(0, 0, bmp.Width, bmp.Height));
gr.Dispose();
}
var fastBmp = new FastBitmap(bmp);
fastBmp.LockImage();
GenerateBitmap(_data, fastBmp, 0, imageTopFieldDataAddress, fourColors, 2);
GenerateBitmap(_data, fastBmp, 1, imageBottomFieldDataAddress, fourColors, 2);
Bitmap cropped = CropBitmapAndUnlok(fastBmp, fourColors[0]);
bmp.Dispose();
return cropped;
}
示例5: DecodeImage
public void DecodeImage(byte[] buffer, int index, ClutDefinitionSegment cds)
{
switch (ObjectCodingMethod)
{
case 0:
var twoToFourBitColorLookup = new List<int> { 0, 1, 2, 3 };
var twoToEightBitColorLookup = new List<int> { 0, 1, 2, 3 };
var fourToEightBitColorLookup = new List<int> { 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15 };
int pixelCode = 0;
int runLength = 0;
int dataType = buffer[index + 7];
int length = TopFieldDataBlockLength;
index += 8;
int start = index;
int x = 0;
int y = 0;
// Pre-decoding to determine image size
int width = 0;
while (index < start + TopFieldDataBlockLength)
{
index = CalculateSize(buffer, index, ref dataType, start, ref x, ref y, length, ref runLength, ref width);
}
if (width > 2000)
{
width = 2000;
}
if (y > 500)
{
y = 500;
}
Image = new Bitmap(width, y + 1);
fastImage = new FastBitmap(Image);
fastImage.LockImage();
x = 0;
y = 0;
index = start;
while (index < start + TopFieldDataBlockLength)
{
index = ProcessDataType(buffer, index, cds, ref dataType, start, twoToFourBitColorLookup, fourToEightBitColorLookup, twoToEightBitColorLookup, ref x, ref y, length, ref pixelCode, ref runLength);
}
x = 0;
y = 1;
if (BottomFieldDataBlockLength == 0)
{
index = start;
}
else
{
length = BottomFieldDataBlockLength;
index = start + TopFieldDataBlockLength;
start = index;
}
dataType = buffer[index - 1];
while (index < start + BottomFieldDataBlockLength - 1)
{
index = ProcessDataType(buffer, index, cds, ref dataType, start, twoToFourBitColorLookup, fourToEightBitColorLookup, twoToEightBitColorLookup, ref x, ref y, length, ref pixelCode, ref runLength);
}
fastImage.UnlockImage();
break;
case 1:
Image = new Bitmap(1, 1);
NumberOfCodes = buffer[index + 3];
break;
}
}
示例6: GetImageTransparentRgba
public Bitmap GetImageTransparentRgba(int index) {
if (ImagesRgba == null || ImagesRgba.Count <= index) {
return null;
}
if (IsDrawnRgba(index) == false) {
DrawRgbaImage(index);
}
Bitmap img = ImagesRgba[index].Image.Clone() as Bitmap;
Color bg = Color.Fuchsia;
FastBitmap fb = new FastBitmap(img);
fb.LockImage();
for (int x = 0; x < img.Width; x++) {
for (int y = 0; y < img.Height; y++) {
if (fb.GetPixel(x, y) == bg) {
fb.SetPixel(x, y, Color.Transparent);
}
}
}
fb.UnlockImage();
return img;
}
示例7: GetImageTransparentPal
public Bitmap GetImageTransparentPal(int index) {
if (ImagesPal == null || ImagesPal.Count <= index) {
return null;
}
if (IsDrawnPal(index) == false) {
if (DrawPalImage(index) == false) {
// TODO: Exception?
return null;
}
}
Bitmap img = ImagesPal[index].Image.Clone() as Bitmap;
Color bg = Palette[0];
FastBitmap fb = new FastBitmap(img);
fb.LockImage();
for (int x = 0; x < img.Width; x++) {
for (int y = 0; y < img.Height; y++) {
if (fb.GetPixel(x, y) == bg) {
fb.SetPixel(x, y, Color.Transparent);
}
}
}
fb.UnlockImage();
return img;
}
示例8: DrawRgbaImage
public bool DrawRgbaImage(int imageIndex) {
if (ImagesRgba == null || ImagesRgba.Count <= imageIndex) {
return false;
}
if (imageIndex < 0 || imageIndex >= ImagesRgba.Count) {
return false;
}
RoSpriteImageRgba sprImg = ImagesRgba[imageIndex];
if (sprImg == null || sprImg.Data == null || sprImg.Data.Length == 0 || sprImg.Width < 1 || sprImg.Height < 1) {
return false;
}
sprImg.Image = new Bitmap(sprImg.Width, sprImg.Height);
FastBitmap fb = new FastBitmap(sprImg.Image);
int index = 0, alpha = 0, red = 0, green = 0, blue = 0;
Color col;
fb.LockImage();
for (int y = 0; y < sprImg.Height; y++) {
for (int x = 0; x < sprImg.Width; x++, index += 4) {
// A B G R
alpha = sprImg.Data[index];
blue = sprImg.Data[index + 1];
green = sprImg.Data[index + 2];
red = sprImg.Data[index + 3];
col = Color.FromArgb(alpha, red, green, blue);
fb.SetPixel(x, y, col);
}
}
fb.UnlockImage();
return true;
}
示例9: DrawPalImage
public bool DrawPalImage(int imageIndex) {
if (ImagesPal == null || ImagesPal.Count <= imageIndex) {
return false;
}
if (imageIndex < 0 || imageIndex >= ImagesPal.Count) {
return false;
}
RoSpriteImagePal sprImg = ImagesPal[imageIndex];
if (Version >= 0x201 && sprImg.Decoded == false) {
sprImg.Data = RLE.Decode(sprImg.Data);
sprImg.Decoded = true;
}
if (sprImg.Data == null || sprImg.Data.Length == 0 || sprImg.Width < 1 || sprImg.Height < 1) {
return false;
}
sprImg.Image = new Bitmap(sprImg.Width, sprImg.Height);
FastBitmap fb = new FastBitmap(sprImg.Image);
int index;
fb.LockImage();
for (int x = 0; x < sprImg.Width; x++) {
for (int y = 0; y < sprImg.Height; y++) {
index = (x + (y * sprImg.Width));
if (index >= sprImg.Data.Length) {
fb.SetPixel(x, y, Color.Transparent);
continue;
}
fb.SetPixel(x, y, Palette[sprImg.Data[index]]);
}
}
fb.UnlockImage();
return true;
}
示例10: GetImageTransparentRgba
public Bitmap GetImageTransparentRgba(int index)
{
if (ImagesRgba == null || ImagesRgba.Count <= index) {
return null;
}
if (IsDrawnRgba(index) == false) {
DrawRgbaImage(index);
}
var img = ImagesRgba[index].Image.Clone() as Bitmap;
if (img == null) {
throw new Exception("Invalid rgba image on index #" + index);
}
var bg = Color.Fuchsia;
var fb = new FastBitmap(img);
fb.LockImage();
for (var x = 0; x < img.Width; x++) {
for (var y = 0; y < img.Height; y++) {
if (fb.GetPixel(x, y) == bg) {
fb.SetPixel(x, y, Color.Transparent);
}
}
}
fb.UnlockImage();
return img;
}
示例11: GetImageTransparentPal
public Bitmap GetImageTransparentPal(int index)
{
if (ImagesPal == null || ImagesPal.Count <= index) {
return null;
}
if (IsDrawnPal(index) == false) {
if (DrawPalImage(index) == false) {
throw new Exception("Failed to draw pal-image on index #" + index);
}
}
var img = ImagesPal[index].Image.Clone() as Bitmap;
if (img == null) {
throw new Exception("Invalid pal image on index #" + index);
}
var bg = Palette[0];
var fb = new FastBitmap(img);
fb.LockImage();
for (var x = 0; x < img.Width; x++) {
for (var y = 0; y < img.Height; y++) {
if (fb.GetPixel(x, y) == bg) {
fb.SetPixel(x, y, Color.Transparent);
}
}
}
fb.UnlockImage();
return img;
}