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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 6, 20262026-06-06T01:34:28+00:00 2026-06-06T01:34:28+00:00

Possible Duplicate: How to get images from URL in Delphi I’m using Delphi 2010,with

  • 0

Possible Duplicate:
How to get images from URL in Delphi

I’m using Delphi 2010,with some functions i can download and show JPG or PNG pictures in cximage or image object in a form, but i’m trying to do without download the picture to hard drive,i was wondering is that possible ? I searched via google & stackoverflow but couldn’t find, all samples are about the download the file.

For example,i added an cximage1 to my form and want to show an picture from an url like “http://www.someaddress.com/pictures/001.JPG“.

Thanks for all helps,and sorry for bad English 🙂

  • 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-06-06T01:34:29+00:00Added an answer on June 6, 2026 at 1:34 am

    You can use this function (compiled and tested using Delphi 2010) to download a file over HTTP and store it in a TBitMap. It’ll read all file types that have a registered support in Delphi’s TGraphic hiearachy, and will auto-detect BMP, GIF, JPG and PNG file formats:

    USES Graphics, IdHTTP, PngImage, jpeg, GIFImg;
    
    FUNCTION DownloadImage(CONST URL : STRING ; ImageType : TGraphicClass = NIL) : TBitMap;
      VAR
        HTTP        : TIdHttp;
        S           : TStream;
        IMG         : TGraphic;
        STR         : AnsiString;
    
      BEGIN
        HTTP:=TIdHttp.Create(NIL);
        TRY
          S:=TMemoryStream.Create;
          TRY
            HTTP.Get(URL,S);
            IF NOT Assigned(ImageType) THEN BEGIN
              S.Position:=0;
              SetLength(STR,5);
              S.Read(STR[1],LENGTH(STR));
              IF COPY(STR,1,2)='BM' THEN
                ImageType:=TBitMap
              ELSE IF COPY(STR,1,3)='GIF' THEN
                ImageType:=TGIFImage
              ELSE IF COPY(STR,2,3)='PNG' THEN
                ImageType:=TPngImage
              ELSE IF (ORD(STR[1])=$FF) AND (ORD(STR[2])=$D8) THEN
                ImageType:=TJPEGImage
            END;
            IF NOT Assigned(ImageType) THEN RAISE EInvalidImage.Create('Unrecognized file format!');
            IMG:=ImageType.Create;
            TRY
              S.Position:=0;
              IMG.LoadFromStream(S);
              Result:=TBitMap.Create;
              TRY
                Result.Assign(IMG)
              EXCEPT
                Result.Free;
                RAISE
              END
            FINALLY
              IMG.Free
            END
          FINALLY
            S.Free
          END
        FINALLY
          HTTP.Free
        END
      END;
    

    If you already know the file type, you can specify it as the 2nd parameter as either TGifImage, TPngImage, TJPegImage or TBitMap. If not, the routine will try to auto-detect it among these four types. If you use a custom-graphic type, you’ll need to specify it as the 2nd parameter or update the auto-detection logic to detect it.

    So, if you want to use it to display a downloaded image in a TImage without saving it to disc, you can use it thus:

      VAR
        BMP : TBitMap;
    
      BEGIN
        BMP:=DownloadImage('http://domain.com/image.jpg');
        TRY
          Image1.Picture.Assign(BMP)
        FINALLY
          BMP.Free
        END
      END;
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Possible Duplicate: get all available fonts from google font api How we can retrieve
Possible Duplicate: how to read images from xml file? how to get images from
Possible Duplicate: Get random item from array I need a code to set a
Possible Duplicate: Get Variable from httpcontext coming from NSUrlRequest This question will be a
Possible Duplicate: Get query string values in JavaScript Say if,i've a URL like this
Possible Duplicate: Get all files from VSS for a given date? I need to
Possible Duplicate: Get URL of ASP.Net Page in code-behind I'm trying to hold current
Possible Duplicate: get image from base64 string I tried header('Content-Type: image/png'); echo base64_decode($data);` But
Possible Duplicate: Best Way to Sprite Images? Hi i have been using this http://spritegen.website-performance.org
Possible Duplicate: Get current URL with JavaScript? How do you get the address of

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.