当前位置:编程学习 > VB >>

用paintpicture方法如何实现90度旋转

--------------------编程问答-------------------- PaintPicture 无法实现。 --------------------编程问答-------------------- 是不是真的啊,太伤心了 --------------------编程问答-------------------- 旋转使用PlgBlt API

The PlgBlt function performs a bit-block transfer of the bits of color data from the specified rectangle in the source device context to the specified parallelogram in the destination device context. If the given bitmask handle identifies a valid monochrome bitmap, the function uses this bitmap to mask the bits of color data from the source rectangle. 

BOOL PlgBlt(
  HDC hdcDest,     // handle to destination device context
  CONST POINT *lpPoint,
                   // vertices of destination parallelogram
  HDC hdcSrc,      // handle to source device context
  int nXSrc,       // x-coord. of upper-left corner of source rect.
  int nYSrc,       // y-coord. of upper-left corner of source rect.
  int nWidth,      // width of source rectangle
  int nHeight,     // height of source rectangle
  HBITMAP hbmMask, // handle to bitmask
  int xMask,       // x-coord. of upper-left corner of bitmask rect.
  int yMask        // y-coord. of upper-left corner of bitmask rect.
);
 
Parameters
hdcDest 
Handle to the destination device context. 
lpPoint 
Pointer to an array of three points in logical space that identify three corners of the destination parallelogram. The upper-left corner of the source rectangle is mapped to the first point in this array, the upper-right corner to the second point in this array, and the lower-left corner to the third point. The lower-right corner of the source rectangle is mapped to the implicit fourth point in the parallelogram. 
hdcSrc 
Handle to the source device context. 
nXSrc 
Specifies the x-coordinate, in logical units, of the upper-left corner of the source rectangle. 
nYSrc 
Specifies the y-coordinate, in logical units, of the upper-left corner of the source rectangle. 
nWidth 
Specifies the width, in logical units, of the source rectangle. 
nHeight 
Specifies the height, in logical units, of the source rectangle. 
hbmMask 
Handle to an optional monochrome bitmap that is used to mask the colors of the source rectangle. 
xMask 
Specifies the x-coordinate of the upper-left corner of the the monochrome bitmap. 
yMask 
Specifies the y-coordinate of the upper-left corner of the the monochrome bitmap. 
Return Values
If the function succeeds, the return value is nonzero.

If the function fails, the return value is zero. 

Windows NT: To get extended error information, callGetLastError. 

Remarks
The fourth vertex of the parallelogram (D) is defined by treating the first three points (A, B, and C) as vectors and computing D = B + C – A. 

If the bitmask exists, a value of 1 in the mask indicates that the source pixel color should be copied to the destination. A value of 0 in the mask indicates that the destination pixel color is not to be changed. 

If the mask rectangle is smaller than the source and destination rectangles, the function replicates the mask pattern. 

Scaling, translation, and reflection transformations are allowed in the source device context; however, rotation and shear transformations are not. 

If the mask bitmap is not a monochrome bitmap, an error occurs. 

The stretching mode for the destination device context is used to determine how to stretch or compress the pixels, if that is necessary. 

When an enhanced metafile is being recorded, an error occurs if the source device context identifies an enhanced-metafile device context. 

The destination coordinates are transformed according to the destination device context; the source coordinates are transformed according to the source device context. If the source transformation has a rotation or shear, an error is returned. 

If the destination and source rectangles do not have the same color format, PlgBlt converts the source rectangle to match the destination rectangle. 

Not all devices support the PlgBlt function. For more information, see the description of the RC_BITBLT raster capability in the GetDeviceCaps function. 

If the source and destination device contexts represent incompatible devices, PlgBlt returns an error. 

--------------------编程问答-------------------- 有没有简单一点的。最好用VB写的 --------------------编程问答-------------------- 用 PaintPicture 应该可以吧 不过效率...
就用循环每一个像素点,然后算好位置 ,再画到另外一个Picturbox上面

不晓得有没有api可以方便一点做到这个?求指点.. --------------------编程问答-------------------- 调用PhotoShop脚本或者用Point函数和PSet方法逐点画?
GDI+似乎有现成的API:
 全部折叠全部展开      代码:全部 代码:多个 代码:Visual Basic 代码:C# 代码:Visual C++ 代码:J# 代码:JScript  
Visual Basic
C#
Visual C++
J#
JScript
Visual C++ 
如何:使用 .NET Framework 旋转图像 
示例  请参见  发送反馈意见 
 

下面的代码示例演示如何使用 System.Drawing..::.Image 类从磁盘中加载图像,将图像旋转 90 度并将其另存为新的 .jpg 文件。

注意: 
GDI+ 由 Windows XP 附带并且可作为 Windows NT 4.0 SP 6、Windows 2000、Windows 98 及 Windows Millennium Edition 的可再发行组件提供。若要下载最新的可再发行组件,请参见 http://go.microsoft.com/fwlink/?linkid=11232。有关更多信息,请参见 GDI+。
 

示例
  复制代码 
#using <system.drawing.dll>

using namespace System;
using namespace System::Drawing;

int main()
{
   Image^ image = Image::FromFile("SampleImage.jpg");
   image->RotateFlip( RotateFlipType::Rotate90FlipNone );
   image->Save("SampleImage_rotated.jpg");
   return 0;
}
 

请参见
概念
.NET 编程指南
发送反馈意见,就此主题向 Microsoft 发送反馈意见。
--------------------编程问答-------------------- 不要做A语言代码修改为B语言代码的无用功。
也不要做用A语言代码直接调用B语言代码库这样复杂、这样容易出错的傻事。
只需让A、B语言代码的输入输出重定向到文本文件,或修改A、B语言代码让其通过文本文件输入输出。
即可很方便地让A、B两种语言之间协调工作。
--------------------编程问答--------------------
引用 1 楼 laviewpbt 的回复:
PaintPicture 无法实现。


我目前知道的API就是水平翻转、垂直翻转,以及组合起来实现的“旋转180°”。
其它角度只有自己写代码来计算处理的。

1F的是这方面的高人,他也说不能实现,我看楼主就别指望着调用几下API实现90°旋转了。
--------------------编程问答-------------------- http://download.csdn.net/detail/veron_04/4814790 --------------------编程问答-------------------- 这里有一个任意角度旋转的例子,就是使用的plgblt函数:

旋转图象示例代码(PlgBlt函数使用示例,VB6.0代码)
补充:VB ,  基础类
CopyRight © 2012 站长网 编程知识问答 www.zzzyk.com All Rights Reserved
部份技术文章来自网络,