bmp

How to capture part of the screen and save it to a BMP? [duplicate]

偶尔善良 提交于 2019-11-29 09:15:21
问题 Possible Duplicate: how to make screen screenshot with win32 in c++? I am currently trying to create an application that saved a portion of the screen to a bmp. I have found BitBlt but I really don't know what to do with it. I have tried searching for some answers but I still haven't found a clarifying one using C++. So, basically I want this function: bool capturePartScreen(int x, int y, int w int, h, string dest){ //Capture part of screen according to coordinates, width and height. //Save

Parse/Read Bitmap file in C

余生长醉 提交于 2019-11-29 08:46:20
I'm trying to make a program to read data from a bitmap file (.bmp, Windows file format, 8bit). Right now I'm stuck on reading the headers before the image data. I used the specifications for bmp that I found here to make these structs to hold the file header, info header, and image data of the bmp: typedef struct { unsigned char fileMarker1; unsigned char fileMarker2; unsigned int bfSize; uint16_t unused1; uint16_t unused2; unsigned int imageDataOffset; } FILEHEADER; typedef struct { unsigned int biSize; int width; int height; uint16_t planes; uint16_t bitPix; unsigned int biCompression;

Converting 1-bit bmp file to array in C/C++

♀尐吖头ヾ 提交于 2019-11-29 07:55:59
I'm looking to turn a 1-bit bmp file of variable height/width into a simple two-dimensional array with values of either 0 or 1. I don't have any experience with image editing in code and most libraries that I've found involve higher bit-depth than what I need. Any help regarding this would be great. Here's the code to read a monochrome .bmp file (See dmb's answer below for a small fix for odd-sized .bmps) #include <stdio.h> #include <string.h> #include <malloc.h> unsigned char *read_bmp(char *fname,int* _w, int* _h) { unsigned char head[54]; FILE *f = fopen(fname,"rb"); // BMP header is 54

Display BMP in JLabel

落爺英雄遲暮 提交于 2019-11-29 07:17:29
Java can display png, jpg a some other picture formats, but i have to display a bmp file in a JLable by getting the file path. ImageIcon imageIcon = new ImageIcon(imageFile.getAbsolutePath()); ImageIcon support the typical png,gif,jpg images. In the project i am working, i can not open a bmp file and store the same file as a jpg, because i am not allow to store something at runtime. I could only generate the image in hold it in memory. But i dont know how to do this. How can i show BMP in Java 1.4 ? Thanks javax.imageio.ImageIO supports the BMP format: Image image = ImageIO.read(imageFile);

How to draw 32-bit alpha channel bitmaps?

谁说胖子不能爱 提交于 2019-11-29 01:37:05
问题 I need to create a custom control to display bmp images with alpha channel. The background can be painted in different colors and the images have shadows so I need to truly "paint" the alpha channel. Does anybody know how to do it? I also want if possible to create a mask using the alpha channel information to know whether the mouse has been click on the image or on the transparent area. Any kind of help will be appreciated! Thanks. Edited(JDePedro): As some of you have suggested I've been

How do I create a BMP file with pure Python?

时光怂恿深爱的人放手 提交于 2019-11-28 23:43:49
I need to create a black and white BMP file with pure Python. I read an article on wikipedia, BMP file format , but I am not good at low level programming and want to fill this gap in my knowledge. So the question is, how do I create a black and white BMP file having a matrix of pixels? I need to do this with pure Python, not using any modules like PIL. It is just for my education. Eli Bendersky construct is a pure-Python library for parsing and building binary structures, protocols and file formats. It has BMP format support out-of-the-box. This could be a better approach than hand-crafting

cannot convert parameter 1 from 'char *' to 'LPCWSTR'

 ̄綄美尐妖づ 提交于 2019-11-28 23:17:12
Im trying to load a BMP file AUX_RGBImageRec *LoadBMP(char *Filename) // Loads A Bitmap Image { FILE *File=NULL; // File Handle if (!Filename) // Make Sure A Filename Was Given { return NULL; // If Not Return NULL } File=fopen(Filename,"r"); // Check To See If The File Exists if (File) // Does The File Exist? { fclose(File); // Close The Handle return auxDIBImageLoad(Filename); // Load The Bitmap And Return A Pointer } return NULL; // If Load Failed Return NULL } this has come from an example however i'm now getting the error error C2664: 'auxDIBImageLoadW' : cannot convert parameter 1 from

Creating a BMP file (bitmap) in C

让人想犯罪 __ 提交于 2019-11-28 19:36:18
I'm trying to make a bitmap in C, just from code. I'm currently trying to make a very easy .bmp image, with a height of 1px and a width of 4 pixels, with all white pixels. I have read the format description and tried to apply it. This resulted in the following code: char bitmap[1000]; void BMPmake() { // -- FILE HEADER -- // // bitmap signature bitmap[0] = 'B'; bitmap[1] = 'M'; // file size bitmap[2] = 66; // 40 + 14 + 12 bitmap[3] = 0; bitmap[4] = 0; bitmap[5] = 0; // reserved field (in hex. 00 00 00 00) for(int i = 6; i < 10; i++) bitmap[i] = 0; // offset of pixel data inside the image for

Function for BMP color inverting doesn't work

霸气de小男生 提交于 2019-11-28 13:04:44
问题 I wrote some quick code that is supposed to invert colors of a BMP image. I test with a 40x40 dimensional BMP image, created by paint. However the function seem to fill it entirelly with white pixels instead. void negate (char *FILE_NAME) { FILE* fp = fopen(FILE_NAME, "r+b"); uint_64 raw_data, i; fseek(fp, 35, SEEK_SET); //raw_data = fgetc(fp) + fgetc(fp)*256; raw_data = 4800; // calculated fseek(fp, 54, SEEK_SET); for(i = 54; i != 54 + raw_data; i++) // <= { int old = fgetc(fp); fseek(fp, i,

BufferedImage to BMP in Java

让人想犯罪 __ 提交于 2019-11-28 12:15:39
I have a BufferedImage object and I want to encode it to the BMP format and save it to disk. How do I do this? In JPEG it's ok: BufferedImage img; //here is an image ready to be recorded into the hard disk FileOutputStream fout = new FileOutputStream("image.jpg"); JPEGImageEncoder jencoder = JPEGCodec.createJPEGEncoder(fout); JPEGEncodeParam enParam = jencoder.getDefaultJPEGEncodeParam(img); enParam.setQuality(1.0F, true); jencoder.setJPEGEncodeParam(enParam); jencoder.encode(img); fout.close(); Marc Use ImageIO - ImageIO.write(img, "BMP", new File("filename.bmp")) Something like this should