Beispiel #1
0
        // ==========================================================================
        // make the cells of 1 frame, called during stage 1, but used mainly
        // for stage 2
        // return 0 on success, non-zero if error
        int dcc_prepare_frame_cells(int d, int f)
        {
            int frame_w, frame_h, w, h, tmp,
                nb_cell_w, nb_cell_h, nb_cell,
                i, x0, y0, x, y;

            int[] cell_w, cell_h;

            frame_w = dcc_direction_headers[d].frame_headers[f].box.width;
            frame_h = dcc_direction_headers[d].frame_headers[f].box.height;

            // width (in # of pixels) in 1st column
            w = 4 - ((dcc_direction_headers[d].frame_headers[f].box.xmin - dcc_direction_headers[d].box.xmin) % 4);

            if ((frame_w - w) <= 1) // if 2nd column is 0 or 1 pixel width
            {
                nb_cell_w = 1;
            }
            else
            {
                // so, we have minimum 2 pixels behind 1st column
                tmp       = frame_w - w - 1; // tmp is minimum 1, can't be 0
                nb_cell_w = 2 + (tmp / 4);
                if ((tmp % 4) == 0)
                {
                    nb_cell_w--;
                }
            }

            h = 4 - ((dcc_direction_headers[d].frame_headers[f].box.ymin - dcc_direction_headers[d].box.ymin) % 4);


            if ((frame_h - h) <= 1)
            {
                nb_cell_h = 1;
            }
            else
            {
                tmp       = frame_h - h - 1;
                nb_cell_h = 2 + (tmp / 4);
                if ((tmp % 4) == 0)
                {
                    nb_cell_h--;
                }
            }

            nb_cell = nb_cell_w * nb_cell_h;

            dcc_direction_headers[d].frame_headers[f].cells = new DCC_CELL_S[nb_cell];
            cell_w = new int[nb_cell_w];
            cell_h = new int[nb_cell_h];


            if (nb_cell_w == 1)
            {
                cell_w[0] = frame_w;
            }
            else
            {
                cell_w[0] = w;
                for (i = 1; i < (nb_cell_w - 1); i++)
                {
                    cell_w[i] = 4;
                }
                cell_w[nb_cell_w - 1] = frame_w - w - (4 * (nb_cell_w - 2));
            }

            if (nb_cell_h == 1)
            {
                cell_h[0] = frame_h;
            }
            else
            {
                cell_h[0] = h;
                for (i = 1; i < (nb_cell_h - 1); i++)
                {
                    cell_h[i] = 4;
                }
                cell_h[nb_cell_h - 1] = frame_h - h - (4 * (nb_cell_h - 2));
            }

            dcc_direction_headers[d].frame_headers[f].nb_cells_w = nb_cell_w;
            dcc_direction_headers[d].frame_headers[f].nb_cells_h = nb_cell_h;

            y0 = dcc_direction_headers[d].frame_headers[f].box.ymin - dcc_direction_headers[d].box.ymin;
            DCC_CELL_S cell = new DCC_CELL_S();

            for (y = 0; y < nb_cell_h; y++)
            {
                x0 = dcc_direction_headers[d].frame_headers[f].box.xmin - dcc_direction_headers[d].box.xmin;

                for (x = 0; x < nb_cell_w; x++)
                {
                    cell     = new DCC_CELL_S();
                    cell.x0  = x0;
                    cell.y0  = y0;
                    cell.w   = cell_w[x];
                    cell.h   = cell_h[y];
                    cell.bmp = new Bitmap(cell.w, cell.h); //x0, y0,

                    using (var g = Graphics.FromImage(cell.bmp))
                    {
                        g.Clear(Color.Yellow);
                    }

                    dcc_direction_headers[d].frame_headers[f].cells[x + (y * nb_cell_w)] = cell;

                    x0 += cell.w;
                }
                y0 += cell.h;
            }

            return(0);
        }
Beispiel #2
0
        int dcc_prepare_buffer_cells(int directionIndex)
        {
            int buffer_w, buffer_h, tmp, nb_cell_w, nb_cell_h, nb_cell, i, x0, y0, x, y;

            int[] cell_w, cell_h;

            buffer_w = dcc_direction_headers[directionIndex].box.width;
            buffer_h = dcc_direction_headers[directionIndex].box.height;


            tmp       = buffer_w - 1;
            nb_cell_w = 1 + (tmp / 4);

            tmp       = buffer_h - 1;
            nb_cell_h = 1 + (tmp / 4);

            nb_cell = nb_cell_w * nb_cell_h;

            dcc_direction_headers[directionIndex].cells = new DCC_CELL_S[nb_cell];
            cell_w = new int[nb_cell_w];
            cell_h = new int[nb_cell_h];


            if (nb_cell_w == 1)
            {
                cell_w[0] = buffer_w;
            }
            else
            {
                for (i = 0; i < (nb_cell_w - 1); i++)
                {
                    cell_w[i] = 4;
                }

                cell_w[nb_cell_w - 1] = buffer_w - (4 * (nb_cell_w - 1));
            }

            if (nb_cell_h == 1)
            {
                cell_h[0] = buffer_h;
            }
            else
            {
                for (i = 0; i < (nb_cell_h - 1); i++)
                {
                    cell_h[i] = 4;
                }

                cell_h[nb_cell_h - 1] = buffer_h - (4 * (nb_cell_h - 1));
            }

            dcc_direction_headers[directionIndex].nb_cells_w = nb_cell_w;
            dcc_direction_headers[directionIndex].nb_cells_h = nb_cell_h;

            y0 = 0;
            for (y = 0; y < nb_cell_h; y++)
            {
                x0 = 0;
                for (x = 0; x < nb_cell_w; x++)
                {
                    var cell = new DCC_CELL_S();
                    cell.w   = cell_w[x];
                    cell.h   = cell_h[y];
                    cell.bmp = new Bitmap(cell.w, cell.h); //x0, y0,

                    using (var g = Graphics.FromImage(cell.bmp))
                    {
                        g.Clear(Color.Blue);
                    }

                    dcc_direction_headers[directionIndex].cells[x + (y * nb_cell_w)] = cell;

                    x0 += 4;
                }
                y0 += 4;
            }

            return(0);
        }