
HBITMAP hBmp;
//
BITMAP bmpInfo;
GetObject((HGDIOBJ)hBmp, sizeof(bmpInfo), &bmpInfo);
//bmpInfobmWidth和bmpInfobmHeight应该是你想要的
各点像素:
先创建一个DC(比如CreateDC("DISPLAY", 0, 0, 0)这样?),然后SelectObject把你的HBITMAP选进去,之后用GetPixel函数可以获取上面的像素点
1、控制大小和位置
/
可以直接调用getWindow(),表示获得这个Activity的Window
对象,这样这可以以同样的方式改变这个Activity的属性
/
Window dialogWindow = dialoggetWindow();
WindowManagerLayoutParams lp = dialogWindowgetAttributes();
dialogWindowsetGravity(GravityLEFT | GravityTOP);
/
lpx与lpy表示相对于原始位置的偏移
当参数值包含GravityLEFT时,对话框出现在左边,所以lpx就表示相对左边的偏移,负值忽略
当参数值包含GravityRIGHT时,对话框出现在右边,所以lpx就表示相对右边的偏移,负值忽略
当参数值包含GravityTOP时,对话框出现在上边,所以lpy就表示相对上边的偏移,负值忽略
当参数值包含GravityBOTTOM时,对话框出现在下边,所以lpy就表示相对下边的偏移,负值忽略
当参数值包含GravityCENTER_HORIZONTAL时
,对话框水平居中,所以lpx就表示在水平居中的位置移动lpx像素,正值向右移动,负值向左移动
当参数值包含GravityCENTER_VERTICAL时
,对话框垂直居中,所以lpy就表示在垂直居中的位置移动lpy像素,正值向右移动,负值向左移动
gravity的默认值为GravityCENTER,即GravityCENTER_HORIZONTAL |
GravityCENTER_VERTICAL
本来setGravity的参数值为GravityLEFT | GravityTOP时对话框应出现在程序的左上角,但在
我手机上测试时发现距左边与上边都有一小段距离,而且垂直坐标把程序标题栏也计算在内了,
GravityLEFT, GravityTOP, GravityBOTTOM与GravityRIGHT都是如此,据边界有一小段距离
/
lpx = 100; // 新位置X坐标
lpy = 100; // 新位置Y坐标
lpwidth = 300; // 宽度
lpheight = 300; // 高度
lpalpha = 07f; // 透明度
// 当Window的Attributes改变时系统会调用此函数,可以直接调用以应用上面对窗口参数的更改,也可以用setAttributes
// dialogonWindowAttributesChanged(lp);
dialogWindowsetAttributes(lp);
/
将对话框的大小按屏幕大小的百分比设置
/
// WindowManager m = getWindowManager();
// Display d = mgetDefaultDisplay(); // 获取屏幕宽、高用
// WindowManagerLayoutParams p = getWindow()getAttributes(); // 获取对话框当前的参数值
// pheight = (int) (dgetHeight() 06); // 高度设置为屏幕的06
// pwidth = (int) (dgetWidth() 065); // 宽度设置为屏幕的095
// dialogWindowsetAttributes(p);
《android逆向视频》百度网盘资源免费下载
5yme
android逆向视频|第一章:Android Java 逆向基础|第五章:Android arm native 逆向|第四章:Android 系统编译|第三章:阶段考核|第七章:Android 应用脱壳|第六章:Android 应用初步编程保护|第二章:Android Hook 插件开发|第八章:Android 应用保护|课时4 Android 加壳保护工具编写3mp4|课时3 Android 加壳保护工具编写2mp4|课时2 Android 加壳保护工具编写1mp4|课时1 Android 加壳原理mp4|课时3 快速Hook代码搭建之 Xposedmp4|课时2 快速Hook代码搭建之 Cydia Substratemp4
我写过一个 从屏幕上截图到clipboard里 (相当于按print-screen键,或 我这里有一个 按 Alt+print-screen键),然后存为BMP的子程序。你稍作修改(例如改一下存放的文件名,添主程序和函数调用)就可以用。
// ---dib functions 函数原型-----
int GetBytesPerPixel(int depth);
int GetBytesPerRow(int width, int depth);
int GetBitmapBytes(int width, int height, int depth);
void save_clipboard_img_to_bmp();
// ---------函数定义---------
int GetBytesPerPixel(int depth)
{ return (depth==32 4 : 3);
}
int GetBytesPerRow(int width, int depth)
{
int bytesPerPixel = GetBytesPerPixel(depth);
int bytesPerRow = ((width bytesPerPixel + 3) & ~3);
return bytesPerRow;
}
// bmibmiHeaderbiWidth, bmibmiHeaderbiHeight, bmibmiHeaderbiBitCount
int GetBitmapBytes(int width, int height, int depth)
{
return height GetBytesPerRow(width, depth);
}
void save_clipboard_img_to_bmp()
{
char nameout[80];
HANDLE h_bitmap,h_dib;
BITMAPINFO bmi;
HDC hDC;
int imageBytes;
BITMAPFILEHEADER hdr;
int scanLineCount;
unsigned char img;
if (!OpenClipboard(NULL)) {
printf("Can not open clipboard\n");
exit(0);
};
if (DEBUG ==1) printf("pass open clipboard\n");
// HANDLE GetClipboardData(UINT uFormat);
h_bitmap = GetClipboardData(CF_BITMAP);
h_dib = GetClipboardData(CF_DIB);
if (h_bitmap ==NULL || h_dib ==NULL){
printf("I got NULL bitmap: ");
} else { printf("I got bitmap: ");};
memcpy(&bmi,h_dib,sizeof(bmi));
printf("%d x %d \n",bmibmiHeaderbiWidth, bmibmiHeaderbiHeight);
hDC = CreateCompatibleDC(NULL); // Gdi32lib
CloseClipboard();
bmibmiHeaderbiCompression = BI_RGB;
// possible to use part of imgage with img_w,img_h
imageBytes = GetBitmapBytes(bmibmiHeaderbiWidth, bmibmiHeaderbiHeight, bmibmiHeaderbiBitCount);
printf("pass GetBitmapBytes=%d \n",imageBytes);
img = (char ) malloc(imageBytes);
if (!img) {
printf("No enought memory for img !\n"); exit(0);
}
// BITMAPFILEHEADER hdr;
hdrbfType = ((WORD) ('M' << 8) | 'B'); // is always "BM"
hdrbfSize = sizeof(BITMAPFILEHEADER) + sizeof(BITMAPINFOHEADER)
+ (bmibmiHeaderbiClrUsed sizeof(RGBQUAD)) + bmibmiHeaderbiSizeImage;
hdrbfReserved1 = 0;
hdrbfReserved2 = 0;
hdrbfOffBits = sizeof(BITMAPFILEHEADER) + sizeof(BITMAPINFOHEADER)
+ (bmibmiHeaderbiClrUsed sizeof(RGBQUAD));
scanLineCount = GetDIBits(hDC,h_bitmap,0,bmibmiHeaderbiHeight, img, &bmi, DIB_RGB_COLORS);
strcpy(nameout,"keyb_tmpbmp");
if ( (fout = fopen(nameout,"wb") ) == NULL ) {
printf("\007Cann't open output file: %s ", nameout);exit(1);
};
fwrite( &hdr, sizeof(BITMAPFILEHEADER ), 1, fout );
fwrite( &bmi, sizeof(BITMAPINFO), 1, fout );
fwrite( img, sizeof(unsigned char),imageBytes, fout );
fclose(fout);
printf("Output in %s\n",nameout);
}
/ --------------------end dib and bmp -------------------- /
以acd看图为例:
在默认状态下,选中后,在状态栏会显示图像的信息,有图像KB大小也有长宽尺寸,
不过这样一个一个查看太慢了,按Alt + O快捷键或者选择工具菜单>选项,打开选项设置窗口,
选择左侧文件列表>缩略图显示,再点击右侧的缩略图信息
在d出的选取缩略图显示信息中展开图像属性:勾图像大小,展开文件属性:勾选大小(KB)
点击添加按钮,添加到当前显示明细中,点击确定,返回选项窗口,点击确定。
看缩略图下面很清楚的显示出了图像大小,也就是长宽像素值,还有KB大小。
以上就是关于如何获得一个HBITMAP指向的BMP图片的尺寸和各点的像素谢谢!全部的内容,包括:如何获得一个HBITMAP指向的BMP图片的尺寸和各点的像素谢谢!、android怎么获取图片的大小、android视频流处理等相关内容解答,如果想了解更多相关内容,可以关注我们,你们的支持是我们更新的动力!
欢迎分享,转载请注明来源:内存溢出
微信扫一扫
支付宝扫一扫
评论列表(0条)