emwin图片旋转
emwin图片旋转默认是用以图片中心为基点旋转的
以下两个测试验证都可以,不要用bitmap旋转,不要用bitmap旋转,不要用bitmap旋转
1.手动内存设备旋转
重点是不要用bitmap,之前移植用bitmap旋转出来效果移植不好,而且不同图片旋转出来效果不同.
以下这个例程是从emwin Memory Device - Rotate (Sample)稍加修改的,因为jpg占用ram较大,所以改了png的试了下可以旋转。
png图片用Bin2C.exe 转成数组
void rotate_test(void)
{
#define ROTATION_ANGLE 45
#define MAGNIFICATION 1
GUI_MEMDEV_Handle hMem;
GUI_MEMDEV_Handle hMemR;
extern const unsigned char _acpointer_png[28783UL + 1];
//
// Init emWin.
//
//GUI_Init();
//
// Get info about the JPEG image.
//
// GUI_JPEG_GetInfo(acseggerlogo, sizeof(acseggerlogo), &Info);
//
// Create memory devices.
// A fixed color depth with 32bpp is necessary for rotating
//
hMem = GUI_MEMDEV_CreateFixed32(0, 0, Info.XSize, Info.YSize);
//
// Select the memory device.
//
GUI_MEMDEV_Select(hMem);
//
// Execute drawing operation.
//
//GUI_JPEG_Draw(acseggerlogo, sizeof(acseggerlogo), 0, 0);
GUI_PNG_Draw(_acpointer_png,28783UL + 1,0,0);
//
// Clear selection
//
GUI_MEMDEV_Select(0);
//
// Create memory device for rotation.
//
hMemR = GUI_MEMDEV_CreateFixed32(0, 0, 200, 200);
//
// Select the memory and clear it.
//
GUI_MEMDEV_Select(hMemR);
GUI_SetBkColor(GUI_BLACK);
GUI_Clear();
GUI_MEMDEV_Select(0);
//
// Execute rotating operation.
// The contents of the first memory device is rotated and copied into the second one.
//
GUI_MEMDEV_RotateHQHR(hMem, hMemR, 0, 0, ROTATION_ANGLE * 1000, MAGNIFICATION * 1000);
//
// Copy memory device to the display
//
GUI_MEMDEV_WriteAt(hMem, 0, 0);
GUI_MEMDEV_WriteAt(hMemR, 100, 50);
//
// Delete memory devices if not needed anymore to free up memory.
//
GUI_MEMDEV_Delete(hMem);
GUI_MEMDEV_Delete(hMemR);
}
2.Image控件形式旋转
这个之前也是用bitmap测试,设置角度后直接就没有图片了,测试1后尝试了用png图片就可以旋转的了
IMAGE_point[0] = IMAGE_CreateEx(0, 0, 84, 85, root, WM_CF_SHOW, IMAGE_CF_MEMDEV, GUI_ID_USER_IMAGE_0);
//IMAGE_EnableLQ(IMAGE_point[0],1);
//IMAGE_SetAngle(IMAGE_point[0],10);
IMAGE_SetAlign(IMAGE_point[0], GUI_ALIGN_CENTER);
//IMAGE_SetBitmap(IMAGE_point[0], &bmpointer);
extern const unsigned char _acpointer_png[28783UL + 1];
IMAGE_SetPNG(IMAGE_point[0],_acpointer_png,28783UL + 1);
IMAGE_SetAngle(IMAGE_point[0],60*1000);