Announcement

Collapse
No announcement yet.

Does #RESOURCE allow .jpg files

Collapse
X
 
  • Filter
  • Time
  • Show
Clear All
new posts

  • Does #RESOURCE allow .jpg files

    Under the topic for #RESOURCE, the help file shows how to create a resource for .ico and .bmp files, but not .jpg.

    I'm wondering if .jpgs are implied with something else, or just not possible at all.

    Thanks,
    -John

  • #2
    You can't store it as a directly usable image, you need to store it as RCDATA and manipulate it. There's code here somewhere to do it using GDI+

    Comment


    • #3
      OK, I'll search gbThreads for keywords like those, as soon as I re-install it!

      Thanks,
      -John

      Comment


      • #4
        Gary had a Asteroids program that used "#Resource RcData, xbackgroundf, "images\backgroundf.jpg" '10"

        Comment


        • #5
          Hi John,

          https://forum.powerbasic.com/forum/j...ge-as-resource

          Comment


          • #6
            Thanks Frank and Manuel, great info!

            Although the code in that other thread is WAY beyond my knowledge level, I'll start by imitation and see how far that gets me!

            Thanks,
            -John

            Comment


            • #7
              Hi John,
              Stuart is right. The #Resource has no specific JPG support.

              As far as simplicity goes, you're much better of converting the JPG to a BMP, which #Resource does support.

              If you must use the JPG, then do this to put the JPG in the EXE ...

              Code:
              #Resource RcData, xbackground, "images\background.jpg" '5

              Then extract the JPG resource to a file, like this:

              ExtractResource("xbackground", "images\background.jpg")

              Code:
              Sub ExtractResource(resName$,fName$)
                 Local temp$
                 temp$ = Resource$(RcData,resName$)
                 Open fName$ For Binary As #1
                 Put #1, , Abs temp$
                 Close #1
              End Sub
              But, then you must add code to load the JPG, which converts it back to a JPG for use with PBWin statements. The "LoadImageToMemoryBitmap" function in gbAsteroids shows how that can be done.

              So you can see that starting with a BMP is way easier.

              Comment


              • #8
                Oh - and yes, Manuel's link to my previously posted solution is appropriate. See post #2 in that link.

                Comment


                • #9
                  It is perfectly legal to use anything as resource including jpg/jpeg images using directly the core API and RT_RCDATA altogether with a Stream
                  GDImage has two functions to achieve this
                  ZI_LoadFromResource
                  ZI_ImageFromResource
                  Patrice Terrier
                  www.zapsolution.com
                  www.objreader.com
                  Addons: GDImage.DLL 32/64-bit (Graphic library), WinLIFT.DLL 32/64-bit (Skin Engine).

                  Comment


                  • #10
                    Gary thanks for the road map, I'll check gbAsteroids and see what I can do.

                    And thanks Patrice for those references - I'll be reading up on them over the weekend.

                    -John

                    Comment

                    Working...
                    X