var
PNG:TPNGObject;  
  
  try
    PNG:=TPNGObject.Create;
    PNG.LoadFromFile('./toolbar/分针.png');
    Image1.Picture.Assign(Png);
  finally
    Png.Free;
  end;怎么对Image1的“分针.PNG”进行旋转,使其指向不同的方向。
在线等待........求救

解决方案 »

  1.   

    可以用GDI+处理png图片,还有画布的旋转,参考如下代码:
    //....
    implementationuses ActiveX;type
      DebugEventLevel = (
        DebugEventLevelFatal,
        DebugEventLevelWarning
      );
      TDebugEventLevel = DebugEventLevel;  DebugEventProc = procedure(level: DebugEventLevel; message: PChar); stdcall;  GdiplusStartupInput = packed record
        GdiplusVersion: Cardinal;
        DebugEventCallback: DebugEventProc;
        SuppressBackgroundThread: BOOL;
        SuppressExternalCodecs: BOOL;
      end;
      TGdiplusStartupInput = GdiplusStartupInput;
      PGdiplusStartupInput = ^TGdiplusStartupInput;  NotificationHookProc = function(out token: ULONG): Integer; stdcall;
      NotificationUnhookProc = procedure(token: ULONG); stdcall;  GdiplusStartupOutput = packed record
        NotificationHook  : NotificationHookProc;
        NotificationUnhook: NotificationUnhookProc;
      end;
      TGdiplusStartupOutput = GdiplusStartupOutput;
      PGdiplusStartupOutput = ^TGdiplusStartupOutput;function GdipCreateBitmapFromFile(filename: PWChar; out bitmap: THandle): Integer;
      stdcall; external 'gdiplus.dll';function GdipDisposeImage(image: THandle): Integer; stdcall;
      stdcall; external 'gdiplus.dll';function GdiplusStartup(out token: ULONG; input: PGdiplusStartupInput;
      output: PGdiplusStartupOutput): Integer; stdcall; external 'gdiplus.dll';procedure GdiplusShutdown(token: ULONG); stdcall; external 'gdiplus.dll';function GdipCreateFromHDC(hdc: HDC;
      out graphics: THandle): Integer; stdcall; external 'gdiplus.dll';function GdipDeleteGraphics(graphics: THandle): Integer; stdcall; external 'gdiplus.dll';function GdipDrawImage(graphics: THandle; image: THandle; x: Single;
      y: Single): Integer; stdcall; external 'gdiplus.dll';function GdipRotateWorldTransform(graphics: THandle; angle: Single;
      order: Integer): Integer; stdcall; external 'gdiplus.dll';function GdipTranslateWorldTransform(graphics: THandle; dx, dy: Single;
      order: Integer): Integer; stdcall; external 'gdiplus.dll';procedure TForm1.Button1Click(Sender: TObject);
    var
      vImage: THandle;
      vGraphics: THandle;
    begin
      GdipCreateBitmapFromFile('c:\temp\temp.png', vImage); // 载入
      GdipCreateFromHDC(Canvas.Handle, vGraphics);
      GdipRotateWorldTransform(vGraphics, 45, 0);
      //GdipTranslateWorldTransform(vGraphics, x, y, 0); // 根据旋转的中心计算
      GdipDrawImage(vGraphics, vImage, 0, 0); // 绘制
      GdipDeleteGraphics(vGraphics);
      GdipDisposeImage(vImage);
    end;var
      vStartupInput: TGDIPlusStartupInput;
      vToken: ULONG;initialization
      vStartupInput.DebugEventCallback := nil;
      vStartupInput.SuppressBackgroundThread := False;
      vStartupInput.SuppressExternalCodecs   := False;
      vStartupInput.GdiplusVersion := 1;
      GdiplusStartup(vToken, @vStartupInput, nil);finalization
      GdiplusShutdown(vToken);end.当然也有相关的gdi+的组件和demo楼主可以自己下来看看。
      

  2.   

    http://topic.csdn.net/u/20070708/21/eea841ff-647f-47a1-9259-f072331c7b5f.html?seed=534823055