Results 1 to 4 of 4

Thread: Loading a bitmap from a resource

  1. #1

    Loading a bitmap from a resource

    I am trying to load a 256-colour bitmap into a TImage component from a resource. This is my code:
    [pascal]Image.Picture.Bitmap.LoadFromResourceName(HInstanc e, 'MYBITMAP');[/pascal]
    However, this raises an EResNotFound exception. I have checked that my application has {$R *.res}, and there most definately is a bitmap called 'MYBITMAP'. Can anyone see what could be going wrong?
    [size=10px][ Join us in #pgd on irc.freenode.net ] [ Sign the Petition for a Software Patent Free Europe ][/size]

  2. #2

    Loading a bitmap from a resource

    Dont' use {$R *.RES}, use {$R ResourceFileName.res}. Don't ask me why, it's some kinda bug or something. But using the exact filename seems to remedy the problem.
    My DGDev forum pascal syntax highlight settings:
    <br />[background=#FFFFFF][comment=#8080FF][normal=#000080]
    <br />[number=#C00000][reserved=#000000][string=#00C000]

  3. #3

    Loading a bitmap from a resource

    Sorry to ask this, but are you sure that you've included the resource file properly?

    Bear in mind that *.res includes a resource file with the same filename, but different extension, to the current unit. In other words, if your unit is "my_unit" then it would include "my_unit.res". It doesn't include every resource file in the directory, as you might have thought...
    "All paid jobs absorb and degrade the mind."
    <br />-- Aristotle

  4. #4

    Loading a bitmap from a resource

    The resource file is just the application resource file, as in the one included in the project source file (.dpr). I guess I could try putting it in a separate resource file for that unit.
    [size=10px][ Join us in #pgd on irc.freenode.net ] [ Sign the Petition for a Software Patent Free Europe ][/size]

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •