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 3317682
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 17, 20262026-05-17T22:36:57+00:00 2026-05-17T22:36:57+00:00

I have a class declared in a unit, and it needs to work with

  • 0

I have a class declared in a unit, and it needs to work with a specific bitmap.
It is declared in the DFM of my test unit like this:

  object ImgTop: TImage
    Left = 208
    Top = 568
    Width = 777
    Height = 41
    Picture.Data = {
      0A544A504547496D616765A1CF0000FFD8FFE000104A46494600010101025802
      [truncated]
      };

But in my final unit I won’t be having a dfm.
So is there a way I can declare it in my unit?

===

Thanks, I seem to have it working now, pitty about the size limitations on bitmaps 🙁
Here’s what I did:

In my folder are these files:

imgleft.bmp
imgtop.bmp

This is my resource file called ScanOCRres.rc:

1 RT_BITMAP "imgtop.bmp"
2 RT_BITMAP "imgleft.bmp"

I have set it to automatically execute with C:\Program Files\Borland\Delphi 7\bin\brcc32.exe

It generated the file

ScanOCRres.RES

In my unit I have
implementation

{$R *.dfm}
{$R ScanOCRres.RES}

And here’s my code:

var
  abmp : TBitmap;
begin
  abmp := TBitmap.create;
  abmp.LoadFromResourceID(SysInit.HInstance, 1);
  abmp.free;
end;

I get this error message on the LoadFromResourceID line:

Project Project1.exe raised exception class EAccessViolation with message ‘Access violation at address 0040A2C8 in module ‘Project1.exe’. Read of address 00000001‘

  • 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-17T22:36:58+00:00Added an answer on May 17, 2026 at 10:36 pm

    You could put it in your code, but it wouldn’t be very convenient to work with. Declare an array of bytes and define each byte of your image. Good luck editing it. To load it, I’d wrap the byte array into a TMemoryStream and then use LoadFromStream.

    A better way is to store the image in a resource. Write a resource script file like this:

    1 RT_BITMAP "foo.bmp"
    

    Add that .rc file to your Delphi project, and it will automatically be linked to your program. At run time, load the image with TBitmap.LoadFromResourceId:

    var
      b: TBitmap;
    begin
      b := TBitmap.Create;
      b.LoadFromResourceId(SysInit.HInstance, 1);
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have two classes declared like this: class Object1 { protected ulong guid; protected
I have a class that offers up a few events. That class is declared
I have two classes: Action and MyAction . The latter is declared as: class
I have a boolean variable declared at the top of a class and when
I have an abstract base class and I want to declare a field or
I have class method that returns a list of employees that I can iterate
I have: class MyClass extends MyClass2 implements Serializable { //... } In MyClass2 is
I have class A: public class ClassA<T> Class B derives from A: public class
I have class with internal property: internal virtual StateEnum EnrolmentState { get { ..getter
I have class with a member function that takes a default argument. struct Class

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.