Пример #1
0
    /// <summary>
    /// Returns true if layer was sucessfully added. Creates a layer from the name, position and a copy of image and adds it to the layer manager.
    /// </summary>
    /// <param name="name">The name of the layer</param>
    /// <param name="position">The position of the image relative to the final image</param>
    /// <param name="image">The image this layer will contain a copy of</param>
    /// <param name="flags">Extra data about the layer</param>
    public bool addLayer(string name, Rectangle region, Bitmap image, int flags = 0)
    {
        if (m_layerCurrent == m_maxLayers)
        {
            return(false);
        }

        CanvasFragment fragment = null;
        Bitmap         img      = null;

        // tries to clone even if null
        //if(image != null)
        //    img = (Bitmap)image.Clone();
        try { img = (Bitmap)image.Clone(); }
        catch { img = null; }

        if (img != null)
        {
            fragment = new CanvasFragment(img, region);
        }

        m_layers[m_layerCount] = new Layer(
            m_layerCount,
            name,
            fragment,
            flags);

        m_layerCurrent = m_layerCount;
        m_layerCount++;

        updateTotalSize();
        return(true);
    }
Пример #2
0
    //Vector
    //Filter

    public Layer(int id, string name, CanvasFragment fragment, int flags = 0)
    {
        m_flags.set(flags);
        m_id        = id;
        m_name      = name;
        m_fragment  = fragment;
        m_isVisible = true;
    }
Пример #3
0
    /// <summary>
    /// Sets values to default and disposes of any images the layer contains.
    /// </summary>
    public void clearLayer()
    {
        m_id   = int.MinValue;
        m_name = "";

        if (m_fragment != null)
        {
            m_fragment.clear();
            m_fragment = null;
        }
    }