I have the code written in the .NET (3.5 SP1) Library (DLL) C #. I have to expand this library by class method, which will contain the following signatures:
public byte [] CreateGridImage (int maxXCells, int maxycells, int cellXposition, int cellYPosition) {...} < / Code> This method should do the following:
- Input parameters
maxXCells and maxYCells define x And the size of the grid of cells in the Y direction. Maximum XCells and maxYCells The number of cells in each direction is the size of the individual cell class (so it is like an asymmetric chess board). < Li> Input parameter cellXPosition and cellYPosition within this grid, identify a special cell and this cell should be filled with a cross.
No fancy graphics are necessary, in fact only black grid lines on a white background and X in one of the cells.
The JPG format in the resulting graphic.
The creation of this graphic should be in memory and nothing should be stored in the file on the disk nor painted on the screen.
/ Li> .NET 3.5 SP1 without additional third-party libraries (which I would like to save)?
Which basic steps do I have to follow and what important .NET namespaces, classes and methods I want to know to achieve this goal (especially attracting lines and other simplicity graphical Elements convert "in memory" and result into a byte array in JPG format)? Thanks for the suggestions! Advance!
The following code
byte [] bytes = CreateGridImage (10, 10, 9, 9, 30); Will create a 10x10 grid with a cross in 9x9 position:
A new addition to CreateGridImage, besides a box, semism that sets the size of each "square" in the grid
Public stable byte [] CreateGridImage (int maxXCells, int maxycells, int cellXposition, int cellyposition, int boxSize) {(var bmp = new system, drawing.bitmap (maxXCells * boxSize + 1, maxYCells * box size + 1)) {usage (Graphics g = graphics.f Remijhejh (BMP)) {g.Clear (Color.Yellow); Pen pens = new pen (color black); Pen.Width = 1; // Draw a red rectangle to the back of the cross Rectangle rect = new rectangle (boxed * (cell exposition-1), boxshyce * * (cellopship-1), box size, boxcases); G.FillRectangle (New SolidBrush (Color.Red), rect); // Draw Crow Drainline (Pen, Box Size * (Cell exposition-1), Boxesize * (cell-by-posation-1), box size * cell xposition, box size * cellopation); G. Drone (pen, box size * (cell expansion -1), boxys * cellopation, boxys * cell exposition, boxshype * (cellopation-1)); // Horizontal lines for Aare (intestine I = 0; i
Comments
Post a Comment