当前位置: 首页>>代码示例>>C#>>正文


C# FastBitmap.UnlockBitmap方法代码示例

本文整理汇总了C#中FastBitmap.UnlockBitmap方法的典型用法代码示例。如果您正苦于以下问题:C# FastBitmap.UnlockBitmap方法的具体用法?C# FastBitmap.UnlockBitmap怎么用?C# FastBitmap.UnlockBitmap使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在FastBitmap的用法示例。


在下文中一共展示了FastBitmap.UnlockBitmap方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。

示例1: getImage

		public Bitmap getImage()
		{
			try
			{
				ReadHeader();
			}
			catch(Exception)
			{
				throw new IOException("Open PPM Exception - Couldn't read header!");
			}

			Bitmap bitmap = new Bitmap( width, height );
            FastBitmap fb = new FastBitmap(bitmap);
            fb.LockBitmap();
			
			int x;
			int y;

			try
			{
				for(y = 0; y < height; y++ )				
				{
					for(x = 0; x < width; x++)
					{
                        unsafe
                        {
                            PixelData* pd = fb[x, y];
                            pd->red = (byte)ReadByte();
                            pd->green = (byte)ReadByte();
                            pd->blue = (byte)ReadByte();
                        }
						//bitmap.SetPixel( x, y, Color.FromArgb( makeRgb( ReadByte(), ReadByte(), ReadByte() ) ) ) ;
					}
				}

			}
			catch(Exception)
			{
				throw new IOException("Open PPM Exception - Couldn't read image data!");
			}

            fb.UnlockBitmap();			
			
			_images.Clear();
			_images.Add(bitmap);

			return bitmap;
		}
开发者ID:xuchuansheng,项目名称:GenXSource,代码行数:48,代码来源:PPMImage.cs

示例2: DrawGraph

        public FastBitmap DrawGraph(string StatName)
        {
            Bitmap bitmap = new Bitmap(200, 200, System.Drawing.Imaging.PixelFormat.Format24bppRgb);
            FastBitmap bmp = new FastBitmap(bitmap);
            bmp.LockBitmap();

            ProfilerValueManager statManager = GetStat(StatName);
            double MaxVal = statManager.GetMaxValue();

            double ScaleFactor = 1 / (MaxVal / 200); //We multiply by this so that the graph uses the full space

            ProfilerValueInfo[] Stats = new ProfilerValueInfo[10];
            int i = 0;
            foreach (ProfilerValueInfo info in statManager.GetInfos())
            {
                Stats[i] = info;
                i++;
            }

            for (i = 0; i < Stats.Length; i++)
            {
                //Update the scales
                Stats[i].Value = Stats[i].Value * ScaleFactor;
            }

            for (int x = 200; x > 0; x--)
            {
                for (int y = 200; y > 0; y--)
                {
                    //Note: we do 200-x and 200-y to flip the graph on the X and Y axises
                    if (IsInGraphBar(x, y, Stats))
                        bmp.SetPixel(200 - x, 200 - y, BarColor);
                    else
                    {
                        //Check whether the line needs drawn
                        if (DrawLine(y, ScaleFactor))
                            bmp.SetPixel(200 - x, 200 - y, LineColor);
                        else
                            bmp.SetPixel(200 - x, 200 - y, BackgroundColor);
                    }
                }
            }
            bmp.UnlockBitmap();

            return bmp;
        }
开发者ID:shangcheng,项目名称:Aurora,代码行数:46,代码来源:Profiler.cs

示例3: SculptMap

        public SculptMap(Bitmap bm, int lod)
        {
            int bmW = bm.Width;
            int bmH = bm.Height;

            if (bmW == 0 || bmH == 0)
                throw new Exception("SculptMap: bitmap has no data");

            int numLodPixels = lod*2*lod*2; // (32 * 2)^2  = 64^2 pixels for default sculpt map image

            bool needsScaling = false;

            bool smallMap = bmW*bmH <= lod*lod;

            width = bmW;
            height = bmH;
            while (width*height > numLodPixels)
            {
                width >>= 1;
                height >>= 1;
                needsScaling = true;
            }


            try
            {
                if (needsScaling)
                    bm = ScaleImage(bm, width, height,
                                    InterpolationMode.NearestNeighbor);
            }

            catch (Exception e)
            {
                throw new Exception("Exception in ScaleImage(): e: " + e);
            }

            if (width*height > lod*lod)
            {
                width >>= 1;
                height >>= 1;
            }

            int numBytes = (width + 1)*(height + 1);
            redBytes = new byte[numBytes];
            greenBytes = new byte[numBytes];
            blueBytes = new byte[numBytes];

            FastBitmap unsafeBMP = new FastBitmap(bm);
            unsafeBMP.LockBitmap(); //Lock the bitmap for the unsafe operation

            int byteNdx = 0;

            try
            {
                for (int y = 0; y <= height; y++)
                {
                    for (int x = 0; x <= width; x++)
                    {
                        Color pixel;
                        if (smallMap)
                            pixel = unsafeBMP.GetPixel(x < width ? x : x - 1,
                                                       y < height ? y : y - 1);
                        else
                            pixel = unsafeBMP.GetPixel(x < width ? x*2 : x*2 - 1,
                                                       y < height ? y*2 : y*2 - 1);

                        redBytes[byteNdx] = pixel.R;
                        greenBytes[byteNdx] = pixel.G;
                        blueBytes[byteNdx] = pixel.B;

                        ++byteNdx;
                    }
                }
            }
            catch (Exception e)
            {
                throw new Exception("Caught exception processing byte arrays in SculptMap(): e: " + e);
            }

            //All done, unlock
            unsafeBMP.UnlockBitmap();

            width++;
            height++;
        }
开发者ID:savino1976,项目名称:Aurora-Sim,代码行数:85,代码来源:SculptMap.cs

示例4: GetBitmapFloat

        private Bitmap GetBitmapFloat(double min, double max, ScaleMap scale)
        {
            float[] buf = (float[])DataBuffer;
            double factor = max - min;
            int stride = AxisSize[0];
            int page = AxisSize[0] * AxisSize[1];
            Bitmap bmp = new Bitmap(AxisSize[0], AxisSize[1]);
            FastBitmap fastBmp = new FastBitmap(bmp);

            fastBmp.LockBitmap();
            unsafe
            {
                for (int y = 0; y < AxisSize[1]; y++)
                {
                    int indexY = ((AxisSize[1] - 1) - y);
                    PixelData* pData = fastBmp[0, y];
                    for (int x = 0; x < AxisSize[0]; x++)
                    {
                        if (color)
                        {
                            double datR = buf[(x + indexY * stride)];
                            double datG = buf[(x + indexY * stride) + page];
                            double datB = buf[(x + indexY * stride) + page * 2];
                            if (ContainsBlanks && (double)datR == BlankValue)
                            {
                                *pData++ = new PixelData(0, 0, 0, 0);
                            }
                            else
                            {
                                int r = scale.Map(datR);
                                int g = scale.Map(datG);
                                int b = scale.Map(datB);
                                *pData++ = new PixelData(r, g, b, 255);
                            }
                        }
                        else
                        {
                            double dataValue = buf[x + indexY * stride];
                            if (ContainsBlanks && (double)dataValue == BlankValue)
                            {
                                *pData++ = new PixelData(0, 0, 0, 0);
                            }
                            else
                            {
                                Byte val = scale.Map(dataValue);
                                *pData++ = new PixelData(val, val, val, 255);
                            }
                        }
                    }
                }
            }
            fastBmp.UnlockBitmap();
            return bmp;
        }
开发者ID:ngonzalezromero,项目名称:wwt-windows-client,代码行数:54,代码来源:FitsImage.cs

示例5: Shade

 public Bitmap Shade (Bitmap source, Color shade, float percent, bool greyScale)
 {
     FastBitmap bmp = new FastBitmap (source);
     bmp.LockBitmap ();
     for (int y = 0; y < source.Height; y++) {
         for (int x = 0; x < source.Width; x++) {
             Color c = bmp.GetPixel (x, y);
             if (greyScale) {
                 int luma = (int)(c.R * 0.3 + c.G * 0.59 + c.B * 0.11);
                 bmp.SetPixel (x, y, Color.FromArgb (c.A, luma, luma, luma));
             } else {
                 float amtFrom = 1 - percent;
                 int lumaR = (int)(c.R * amtFrom + shade.R * percent);
                 int lumaG = (int)(c.G * amtFrom + shade.G * percent);
                 int lumaB = (int)(c.B * amtFrom + shade.B * percent);
                 bmp.SetPixel (x, y, Color.FromArgb (c.A, lumaR, lumaG, lumaB));
             }
         }
     }
     bmp.UnlockBitmap ();
     return bmp.Bitmap ();
 }
开发者ID:EnricoNirvana,项目名称:WhiteCore-Dev,代码行数:22,代码来源:WorldShader.cs

示例6: bitmap2Coords

        /// <summary>
        ///   converts a bitmap to a list of lists of coords, while scaling the image.
        ///   the scaling is done in floating point so as to allow for reduced vertex position
        ///   quantization as the position will be averaged between pixel values. this routine will
        ///   likely fail if the bitmap width and height are not powers of 2.
        /// </summary>
        /// <param name = "bitmap"></param>
        /// <param name = "scale"></param>
        /// <param name = "mirror"></param>
        /// <returns></returns>
        private List<List<Coord>> bitmap2Coords(Bitmap bitmap, int scale, bool mirror)
        {
            int numRows = bitmap.Height/scale;
            int numCols = bitmap.Width/scale;
            List<List<Coord>> rows = new List<List<Coord>>(numRows);

            float pixScale = 1.0f/(scale*scale);
            pixScale /= 255;

            int imageX, imageY = 0;

            int rowNdx, colNdx;

            FastBitmap unsafeBMP = new FastBitmap(bitmap);
            unsafeBMP.LockBitmap(); //Lock the bitmap for the unsafe operation

            for (rowNdx = 0; rowNdx < numRows; rowNdx++)
            {
                List<Coord> row = new List<Coord>(numCols);
                for (colNdx = 0; colNdx < numCols; colNdx++)
                {
                    imageX = colNdx*scale;
                    int imageYStart = rowNdx*scale;
                    int imageYEnd = imageYStart + scale;
                    int imageXEnd = imageX + scale;
                    float rSum = 0.0f;
                    float gSum = 0.0f;
                    float bSum = 0.0f;
                    for (; imageX < imageXEnd; imageX++)
                    {
                        for (imageY = imageYStart; imageY < imageYEnd; imageY++)
                        {
                            Color pixel = unsafeBMP.GetPixel(imageX, imageY);

                            if (pixel.A != 255)
                            {
                                pixel = Color.FromArgb(255, pixel.R, pixel.G, pixel.B);
                                unsafeBMP.SetPixel(imageX, imageY, pixel);
                            }
                            rSum += pixel.R;
                            gSum += pixel.G;
                            bSum += pixel.B;
                        }
                    }
                    row.Add(mirror
                                ? new Coord(-(rSum*pixScale - 0.5f), gSum*pixScale - 0.5f, bSum*pixScale - 0.5f)
                                : new Coord(rSum*pixScale - 0.5f, gSum*pixScale - 0.5f, bSum*pixScale - 0.5f));
                }
                rows.Add(row);
            }

            unsafeBMP.UnlockBitmap();

            return rows;
        }
开发者ID:nathanmarck,项目名称:Aurora-Sim,代码行数:65,代码来源:SculptMesh.cs

示例7: DrawGraph

        public FastBitmap DrawGraph(string StatName)
        {
            Bitmap bitmap = new Bitmap(200, 200, PixelFormat.Format24bppRgb);
            FastBitmap bmp = new FastBitmap(bitmap);
            bmp.LockBitmap();

            ProfilerValueManager statManager = GetStat(StatName);
            double MaxVal = 0;
            if (statManager != null)
                MaxVal = statManager.GetMaxValue();

            double ScaleFactor = 1/(MaxVal/200); //We multiply by this so that the graph uses the full space

            double[] Stats2 = new double[0];
            if (statManager != null)
                Stats2 = statManager.GetInfos();

            for (int i = 0; i < Stats2.Length; i++)
            {
                //Update the scales
                Stats2[i] = Stats2[i]*ScaleFactor;
            }

            for (int x = 200; x > 0; x--)
            {
                for (int y = 200; y > 0; y--)
                {
                    //Note: we do 200-y to flip the graph on the Y axis
                    if (IsInGraphBar(x, y, Stats2, ScaleFactor))
                        bmp.SetPixel(x, 200 - y, BarColor);
                    else
                    {
                        //Check whether the line needs drawn
                        bmp.SetPixel(x, 200 - y, DrawLine(y, ScaleFactor) ? LineColor : BackgroundColor);
                    }
                }
            }
            bmp.UnlockBitmap();

            return bmp;
        }
开发者ID:QueenStarfinder,项目名称:WhiteCore-Dev,代码行数:41,代码来源:Profiler.cs

示例8: MakeWarpMap

        public static Bitmap MakeWarpMap(ProjectorEntry pe, double domeSize, bool radialDistortion, List<GroundTruthPoint> gtPointList, ScreenTypes screenType)
        {
            List<Vector2d> PointTo = new List<Vector2d>();
            List<Vector2d> PointFrom = new List<Vector2d>();

            double xFactor = pe.Width / 512.0;
            double yFactor = pe.Height / 512.0;

            Bitmap bmp = new Bitmap(512, 512);
            FastBitmap fastBmp = new FastBitmap(bmp);

            SolveProjector spProjector = new SolveProjector(pe, domeSize, ProjectionType.Projector, screenType, SolveParameters.Default);
            spProjector.RadialDistorion = radialDistortion;

            SolveProjector spView = new SolveProjector(pe, domeSize, ProjectionType.View, ScreenTypes.Spherical, SolveParameters.Default);
            spView.RadialDistorion = false;

            foreach (GroundTruthPoint gt in gtPointList)
            {
                PointFrom.Add(new Vector2d((double)gt.X / (double)pe.Width * 512, (double)gt.Y / (double)pe.Height * 512));

                Vector2d pntOutTarget = spView.ProjectPoint(new Vector2d(gt.Az, gt.Alt));
                Vector2d AltAzMapped = spProjector.GetCoordinatesForScreenPoint(gt.X,gt.Y);
                Vector2d pntOutMapped = spView.ProjectPoint(new Vector2d(AltAzMapped.X, AltAzMapped.Y));

                pntOutTarget.X = pntOutTarget.X *(512 / 2.0) + (512 / 2.0);
                pntOutTarget.Y = pntOutTarget.Y *(-512 / 2.0) + (512 / 2.0);
                pntOutMapped.X = pntOutMapped.X *(512 / 2.0) + (512 / 2.0);
                pntOutMapped.Y =  pntOutMapped.Y *(-512 / 2.0) + (512 / 2.0);

                PointTo.Add(new Vector2d(pntOutTarget.X - pntOutMapped.X, pntOutTarget.Y - pntOutMapped.Y));

            }

            //Matrix3d projMat = spView.GetCameraMatrix();
            unsafe
            {
                fastBmp.LockBitmap();
                for (int y = 0; y < 512; y++)
                {

                    for (int x = 0; x < 512; x++)
                    {
                        Vector2d pnt = spProjector.GetCoordinatesForScreenPoint(x * xFactor, y * yFactor);

                        Vector2d pntOut = spView.ProjectPoint(pnt);

                        // Map
                        pntOut.X = pntOut.X * (512 / 2.0) + (512 / 2.0);
                        pntOut.Y = pntOut.Y * (-512 / 2.0) + (512 / 2.0);

                        pntOut = MapPoint(new Vector2d(x,y), pntOut, PointTo, PointFrom);

                        pntOut.X = (pntOut.X - (512 / 2.0)) / (512 / 2.0);
                        pntOut.Y = (pntOut.Y - (512 / 2.0)) / (-512 / 2.0);
                        // End Map

                        double xo = pntOut.X * (4096 / 2.0) + (4096 / 2.0);
                        double yo = pntOut.Y * (-4096 / 2.0) + (4096 / 2.0);

                        int blue = (int)xo & 255;
                        int green = (int)yo & 255;
                        int red = (((int)yo) >> 4 & 240) + (((int)xo) >> 8 & 15);
                        *fastBmp[x, y] = new PixelData(red, green, blue, 255);

                    }
                }
                fastBmp.UnlockBitmap();

            }
            return bmp;
        }
开发者ID:ngonzalezromero,项目名称:wwt-windows-client,代码行数:72,代码来源:WarpMapper.cs

示例9: DrawGraph

        public FastBitmap DrawGraph(string StatName, double MaxVal)
        {
            Bitmap bitmap = new Bitmap(200, 200, System.Drawing.Imaging.PixelFormat.Format24bppRgb);
            FastBitmap bmp = new FastBitmap(bitmap);
            bmp.LockBitmap();

            ProfilerValueManager statManager = GetStat(StatName);

            double ScaleFactor = 1 / (MaxVal / 200); //We multiply by this so that the graph uses the full space

            double[] Stats = statManager.GetInfos();

            for (int x = 200; x > 0; x--)
            {
                for (int y = 200; y > 0; y--)
                {
                    //Note: we do 200-y to flip the graph on the Y axis
                    if (IsInGraphBar(x, y, Stats, ScaleFactor))
                        bmp.SetPixel(x, 200 - y, BarColor);
                    else
                    {
                        //Check whether the line needs drawn
                        if (DrawLine(y, ScaleFactor))
                            bmp.SetPixel(x, 200 - y, LineColor);
                        else
                            bmp.SetPixel(x, 200 - y, BackgroundColor);
                    }
                }
            }
            bmp.UnlockBitmap();

            return bmp;
        }
开发者ID:rknop,项目名称:Aurora-Sim,代码行数:33,代码来源:Profiler.cs

示例10: BoundingRectangle

        public static Rectangle BoundingRectangle(Bitmap bmp, Rectangle bounds, int bound_color)
        {
            FastBitmap fbmp = new FastBitmap(bmp);
            int s_x = 0, e_x = 0, s_y = 0, e_y = 0; bool done = false;
            for (int x = bounds.X; x < bounds.X + bounds.Width && !done; x++)
            {
                for (int y = bounds.Y; y < bounds.Y + bounds.Height; y++)
                {
                    if (fbmp.GetPixel(x, y) == bound_color)
                    {
                        s_x = x;
                        done = true;
                        break;
                    }
                }
            }
            done = false;
            for (int x = bounds.X + bounds.Width - 1; x >= bounds.X && !done; x--)
            {
                for (int y = bounds.Y; y < bounds.Y + bounds.Height; y++)
                {
                    if (fbmp.GetPixel(x, y) == bound_color)
                    {
                        e_x = x;
                        done = true;
                        break;
                    }
                }
            }
            done = false;
            for (int y = bounds.Y; y < bounds.Y + bounds.Height && !done; y++)
            {
                for (int x = bounds.X; x < bounds.X + bounds.Width; x++)
                {
                    if (fbmp.GetPixel(x, y) == bound_color)
                    {
                        s_y = y;
                        done = true;
                        break;
                    }
                }
            }
            done = false;
            for (int y = bounds.Y + bounds.Height - 1; y >= bounds.Y && !done; y--)
            {
                for (int x = bounds.X; x < bounds.X + bounds.Width; x++)
                {
                    if (fbmp.GetPixel(x, y) == bound_color)
                    {
                        e_y = y;
                        done = true;
                        break;
                    }
                }
            }

            fbmp.UnlockBitmap();

            //Console.WriteLine(s_x + " " + e_x + " " + s_y + " " + e_y);

            Rectangle crop_rect = new Rectangle(s_x, s_y, e_x - s_x + 1, e_y - s_y + 1);

            return crop_rect;
        }
开发者ID:alexhanh,项目名称:Botting-Library,代码行数:64,代码来源:BitmapAnalyzer.cs

示例11: GenerateTransitions

        /// <summary>
        /// Generates transition images of #left and #right pixels to left and right respectfully.
        /// </summary>
        /// <param name="number"></param>
        /// <param name="left"></param>
        /// <param name="right"></param>
        /// <returns></returns>
        public static List<FastBitmap> GenerateTransitions(FastBitmap number, int left, int right)
        {
            List<FastBitmap> transitions = new List<FastBitmap>();

            for (int x = -1 * left; x <= right; x++)
            {
                if (x == 0)
                    continue;

                number.UnlockBitmap();

                Bitmap bitmap = new Bitmap(number.Width, number.Height, number.Bitmap.PixelFormat);
                Graphics g = Graphics.FromImage(bitmap);
                g.Clear(Color.FromArgb(0, 0, 0));

                if (x < 0)
                    g.DrawImageUnscaled(number.Bitmap.Clone(new Rectangle(Math.Abs(x), 0, number.Width - Math.Abs(x), number.Height), number.Bitmap.PixelFormat), 0, 0);
                else
                    g.DrawImageUnscaled(number.Bitmap.Clone(new Rectangle(0, 0, number.Width - x, number.Height), number.Bitmap.PixelFormat), x, 0);

                number.LockBitmap();

                transitions.Add(new FastBitmap(bitmap));
            }

            return transitions;
        }
开发者ID:alexhanh,项目名称:Botting-Library,代码行数:34,代码来源:BitmapAnalyzer.cs

示例12: ComputeMandel

        public void ComputeMandel()
        {
            unsafe
            {
                string filename = this.FileName;
                string path = this.Directory;
                Bitmap b = null;
                PixelData pixel;
                pixel.alpha = 255;
                MAXITER = 100 + level * 38;

                double tileWidth = (4 / (Math.Pow(2, this.level)));
                double Sy = ((double)this.y * tileWidth) - 2;
                double Fy = Sy + tileWidth;
                double Sx = ((double)this.x * tileWidth) - 4;
                double Fx = Sx + tileWidth;

                b = new Bitmap(mandelWidth, mandelWidth);
                FastBitmap fb = new FastBitmap(b);
                fb.LockBitmap();
                double x, y, xmin, xmax, ymin, ymax = 0.0;
                int looper, s, z = 0;
                double intigralX, intigralY = 0.0;
                xmin = Sx;
                ymin = Sy;
                xmax = Fx;
                ymax = Fy;
                intigralX = (xmax - xmin) / mandelWidth;
                intigralY = (ymax - ymin) / mandelWidth;
                x = xmin;

                bool computeAll = true;

                if (computeAll)
                {
                    for (s = 0; s < mandelWidth; s++)
                    {
                        y = ymin;
                        for (z = 0; z < mandelWidth; z++)
                        {

                            looper = MandPoint(x, y);
                            System.Drawing.Color col = (looper == MAXITER) ? System.Drawing.Color.Black : Tile.ColorTable[looper % 1011];
                            pixel.red = col.R;
                            pixel.green = col.G;
                            pixel.blue = col.B;
                            //b.SetPixel(s, z, col);
                            *fb[s, z] = pixel;
                            y += intigralY;
                        }
                        x += intigralX;
                    }
                }

                if (!System.IO.Directory.Exists(path))
                {
                    System.IO.Directory.CreateDirectory(path);
                }
                fb.UnlockBitmap();
                b.Save(filename);
                b.Dispose();
                GC.SuppressFinalize(b);
            }
        }
开发者ID:china-vo,项目名称:wwt-windows-client,代码行数:64,代码来源:Tile.cs

示例13: CreateImage

	private Image CreateImage( byte []data, int w, int h )
	{
		Bitmap retBitmap = new Bitmap( w, h );
        FastBitmap fb = new FastBitmap(retBitmap);
        fb.LockBitmap();

		int pixelCount = 0;

        unsafe
        {
            for (int j = 0; j < h; j++)
            {
                for (int i = 0; i < w; i++)
                {
                    PixelData* pd = fb[i, j];
                    pd->red = data[pixelCount];
                    pd->green = data[pixelCount];
                    pd->blue = data[pixelCount];
                    //retBitmap.SetPixel(i,j,Color.FromArgb( data[ pixelCount ] , data[ pixelCount ], data[ pixelCount ] ) );
                    pixelCount++;
                }
            }
        }

        fb.UnlockBitmap();

		return retBitmap;
	}
开发者ID:xuchuansheng,项目名称:GenXSource,代码行数:28,代码来源:DICOMImage.cs

示例14: HandlePlanar

		private void HandlePlanar(String fileName)
		{
			BinaryReader reader = new BinaryReader(	
				File.Open( fileName, FileMode.Open ) );

			for( int k = 0; k <  nImages; k++ )
			{
				Bitmap retBitmap = new Bitmap( width, height );
                FastBitmap fb = new FastBitmap(retBitmap);
					
				//Skip the offset
				if( offset > 0 )
					reader.ReadBytes( offset );

				int totalPixels = width * height;
				int []r = new int[ totalPixels ];
				int []g = new int[ totalPixels ];
				int []b = new int[ totalPixels ];

				// Read all R colors
				for( int i=0; i < totalPixels; i++ )
				{
					r[i] = ReadPixel( reader );
				}	

				// Read all G colors
				for( int i=0; i < totalPixels; i++ )
				{
					g[i] = ReadPixel( reader );
				}	

				// Read all B colors
				for( int i=0; i < totalPixels; i++ )
				{
					b[i] = ReadPixel( reader );
				}
	
				if( colorOrder == ColorOrder.BGR )
				{
					int []temp = r;
					r = b;
					b = temp;
				}

				int index = 0;

                fb.LockBitmap();

				for( int j=0; j < height; j++ )
				{
					for( int i=0; i < width; i++ )
					{
                        unsafe
                        {
                            PixelData* pd = fb[i, j];
                            pd->red = (byte)r[index];
                            pd->green = (byte)g[index];
                            pd->blue = (byte)b[index];
                        }

						//retBitmap.SetPixel( i,j, Color.FromArgb(r[index], g[index], b[index] ) );
						index ++;
					}
				}
                fb.UnlockBitmap();
				Images.Add( retBitmap );
			}

			reader.BaseStream.Seek(0, SeekOrigin.Begin);
			_imageData = reader.ReadBytes( (int)reader.BaseStream.Length );

			reader.Close();
			
		}
开发者ID:xuchuansheng,项目名称:GenXSource,代码行数:74,代码来源:RAWImage.cs

示例15: HandleInterleaved

		private void HandleInterleaved(String fileName)
		{
			BinaryReader reader = new BinaryReader(	
				File.Open( fileName, FileMode.Open ) );

			for( int k = 0; k <  nImages; k++ )
			{
				Bitmap retBitmap = new Bitmap( width, height );
                FastBitmap fb = new FastBitmap(retBitmap);				
				//Skip the offset
				if( offset > 0 )
					reader.ReadBytes( offset );

                fb.LockBitmap();

				for( int j=0; j < height; j++ )
				{
					for( int i=0; i < width; i++ )
					{
                        unsafe
                        {
                            Color c = ReadColor(reader);
                            PixelData* pd = fb[i, j];
                            pd->red = c.R;
                            pd->green = c.G;
                            pd->blue = c.B;
                        }
						//retBitmap.SetPixel( i,j, ReadColor( reader ) );
					}
				}
                fb.UnlockBitmap();

				Images.Add( retBitmap );
			}

			reader.BaseStream.Seek(0, SeekOrigin.Begin);
			_imageData = reader.ReadBytes( (int)reader.BaseStream.Length );
						
			reader.Close();			
			
		}
开发者ID:xuchuansheng,项目名称:GenXSource,代码行数:41,代码来源:RAWImage.cs


注:本文中的FastBitmap.UnlockBitmap方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。