zoukankan      html  css  js  c++  java
  • 获取指定地址的 JPG 图片 回复 "bangrj" 的问题


    问题来源: http://www.cnblogs.com/del/archive/2009/02/27/1370907.html#1463071

    本例效果图:



    代码文件:
    unit Unit1;
    
    interface
    
    uses
      Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
      Dialogs, IdBaseComponent, IdComponent, IdTCPConnection, IdTCPClient, IdHTTP,
      StdCtrls;
    
    type
      TForm1 = class(TForm)
        Button1: TButton;
        IdHTTP1: TIdHTTP;
        procedure Button1Click(Sender: TObject);
      end;
    
    var
      Form1: TForm1;
    
    implementation
    
    {$R *.dfm}
    
    uses jpeg;
    
    procedure TForm1.Button1Click(Sender: TObject);
    const
      url = 'http://ptlogin2.qq.com/getimage?aid=15000701&0.9129723031485226';
    var
      ms: TMemoryStream;
      jpg: TJPEGImage;
    begin
      ms := TMemoryStream.Create;
      jpg := TJPEGImage.Create;
    
      IdHTTP1.Get(url, ms);
      ms.Position := 0;
    
      jpg.LoadFromStream(ms);
      Canvas.Draw(10, 10, jpg);
    
      jpg.Free;
      ms.Free;
    end;
    
    end.
    

    窗体文件:
    object Form1: TForm1
      Left = 0
      Top = 0
      Caption = 'Form1'
      ClientHeight = 126
      ClientWidth = 158
      Color = clBtnFace
      Font.Charset = DEFAULT_CHARSET
      Font.Color = clWindowText
      Font.Height = -11
      Font.Name = 'Tahoma'
      Font.Style = []
      OldCreateOrder = False
      PixelsPerInch = 96
      TextHeight = 13
      object Button1: TButton
        Left = 40
        Top = 88
        Width = 75
        Height = 25
        Caption = 'Button1'
        TabOrder = 0
        OnClick = Button1Click
      end
      object IdHTTP1: TIdHTTP
        AllowCookies = True
        ProxyParams.BasicAuthentication = False
        ProxyParams.ProxyPort = 0
        Request.ContentLength = -1
        Request.Accept = 'text/html, */*'
        Request.BasicAuthentication = False
        Request.UserAgent = 'Mozilla/3.0 (compatible; Indy Library)'
        HTTPOptions = [hoForceEncodeParams]
        Left = 8
        Top = 8
      end
    end
    

  • 相关阅读:
    POJ1222_EXTENDED LIGHTS OUT
    SGU196_Matrix Multiplication
    ZOJ3772_Calculate the Function
    Triangle POJ
    POJ 2187 Beauty Contest(凸包,旋转卡壳)
    [Neerc2016]Mole Tunnels (模拟费用流)
    [2019ccpc网络赛】K-th occurrence(后缀数组+主席树)
    【HDU2019多校】E
    Gym
    P3160 [CQOI2012]局部极小值(dfs+状压dp)
  • 原文地址:https://www.cnblogs.com/del/p/1399526.html
Copyright © 2011-2022 走看看