Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 7086881
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 28, 20262026-05-28T07:36:18+00:00 2026-05-28T07:36:18+00:00

I have a design question… I want to create my own image class called

  • 0

I have a design question…

I want to create my own image class called EfficientImage which will include a Load which will take a System.Drawing.Bitmap and use lock bits to convert it into a 2D byte array.

class EfficientImage
{

    private byte[,] image;
    private int width;
    private int height;

    public Load(System.Drawing.Bitmap inImage)
    {
    }

    //etc...

}

so i might have

EfficentImage ef = new EfficientImage();
ef.Load(myBitmap);

What is the best way to access the image array within the object without losing the performance gain of using LockBits in the first place? I believe having an accessor or a property would be replicating the GetPixel/SetPixel in a normal Bitmap object which is not efficient and setting the image field to public would break encapsulation

It may be that this design is entirely the wrong way to go but I would be very pleased to learn of a better/correct way.

Thanks for your help

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-28T07:36:19+00:00Added an answer on May 28, 2026 at 7:36 am

    I assume you want to apply some kind of filter to images, or have some other kind of processing that modifies multiple pixels.

    If that is the case, I would call your class something like ImageFilter, for instance:

    public abstract class ImageFilter
    {
        protected abstract void ApplyFilter(byte[,] imageData);
    
        public Bitmap Apply(Bitmap image)
        {
            // lockbits etc
            ApplyFilter(imageData);
            // unlockbits
        }
    }
    
    public class MyFilter : ImageFilter
    {
        protected override ApplyFilter(byte[,] imageData)
        {
            // work on the bits
        }
    }
    
    Bitmap newBitmap = new MyFilter().Apply(oldBitmap);
    

    That way you can write custom filters that deal with the raw data only, while the ImageFilter abstract class deals with loading the image and its data.

    Apologies if I missed the point 🙂

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have a weird design question. I have a model called Article, which has
I have a design question which I think Domain events will solve but I
Just wanted opinions on a design question. If you have a C++ class than
I have a pretty simple question which perhaps someone familiar with Server/Client design &
I have a design question. I want some feedback to know if a ThreadPool
I have a general Database Design question: When is it better to create a
this is a CSS / design question. I have three textboxes that i want
I have a design based question where I want to avoid dynamic_cast but still
I have a design question :) I want to have multiple servlets but I
Design question: I have ViewController A which contains an NSMutableArray*. The ViewController A is

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.