bmp

How to convert 32-bit BMP to contain alpha channel? [closed]

此生再无相见时 提交于 2019-11-30 13:21:24
问题 Closed. This question is off-topic. It is not currently accepting answers. Want to improve this question? Update the question so it's on-topic for Stack Overflow. Closed 3 years ago . I have an PNG image with alpha, I need to convert it to BMP to be loaded to my OpenGL application. However, BMP has only 1 option for 32-bit, that is XRBG where 'X' is just an extra byte for padding purpose (4-byte alignment). The question is how to ultilise this 'X' byte to contain alpha channel, so that the

How to generate a dynamic GRF image to ZPL ZEBRA print

旧城冷巷雨未停 提交于 2019-11-30 09:23:09
I have a problem. I´m generating a dynamic BMP image and trying to send this to a ZEBRA printer by ZPL commands. I need to convert my BMP to a GRF image. I think that my Hexadecimal extracted by the BMP image isn´t correct. The printed image is blurred and incorrect. This is my code: string bitmapFilePath = @oldArquivo; // file is attached to this support article byte[] bitmapFileData = System.IO.File.ReadAllBytes(bitmapFilePath); int fileSize = bitmapFileData.Length; Bitmap ImgTemp = new Bitmap(bitmapFilePath); Size ImgSize = ImgTemp.Size; ImgTemp.Dispose(); // The following is known about

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

故事扮演 提交于 2019-11-30 08:45:41
问题 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. 回答1: 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

How to convert 32-bit BMP to contain alpha channel? [closed]

[亡魂溺海] 提交于 2019-11-30 08:43:26
I have an PNG image with alpha, I need to convert it to BMP to be loaded to my OpenGL application. However, BMP has only 1 option for 32-bit, that is XRBG where 'X' is just an extra byte for padding purpose (4-byte alignment). The question is how to ultilise this 'X' byte to contain alpha channel, so that the BMP (32-bit XRGB) can be loaded to GL application with transparent pixels? Maybe I have to make my own tool to do this conversion? What I need is RGBA, and not 'XRGB' or 'ARGB', do I have to read the XRGB BMP file and scan pixel by pixel to convert to RGBA? Which is the best way in VC++

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

瘦欲@ 提交于 2019-11-30 07:30:53
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 that captured image as a bmp to dest. //Return true if success, false if failure } BitBlt: BOOL BitBlt(

ImageIO.write bmp does not work

泄露秘密 提交于 2019-11-30 06:51:09
I'm trying to save an image in bmp format, but it doesn't create any file. If I use "png" instead, everything works fine. Any ideas? //This works fine: ImageIO.write(bi, "png", new File("D:\\MyImage.png")); //This does not work: ImageIO.write(bi, "bmp", new File("D:\\MyImage.bmp")); ImageIO.getWriterFormatNames() gives me "jpg", "bmp", "jpeg" and some others.. Thanks in advance. Jakob I just finished debugging a similar problem and I thought I will present my reasoning here, although Jakob has gone ahead with the PNG format. First, always check the return value of ImageIO.write(...) . It will

How to draw 32-bit alpha channel bitmaps?

拈花ヽ惹草 提交于 2019-11-30 04:12:57
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 trying to use alpha blend to paint the bitmap with alpha channel. This just a test I've implemented where

Why does fread mess with my byte order?

ⅰ亾dé卋堺 提交于 2019-11-30 02:16:08
Im trying to parse a bmp file with fread() and when I begin to parse, it reverses the order of my bytes. typedef struct{ short magic_number; int file_size; short reserved_bytes[2]; int data_offset; }BMPHeader; ... BMPHeader header; ... The hex data is 42 4D 36 00 03 00 00 00 00 00 36 00 00 00 ; I am loading the hex data into the struct by fread(&header,14,1,fileIn); My problem is where the magic number should be 0x424d //'BM' fread() it flips the bytes to be 0x4d42 // 'MB' Why does fread() do this and how can I fix it; EDIT: If I wasn't specific enough, I need to read the whole chunk of hex

How to access each byte in a bitmap image

一个人想着一个人 提交于 2019-11-29 23:45:55
问题 Say I have a bitmap image, is it possible to iterate through all the individual bytes in the image? If yes, how? 回答1: I found this: http://channel9.msdn.com/forums/TechOff/108813-Bitmap-to-byte-array/ Saying that you could use a Memorystream and the .Save method it'd look like this: System.Drawing.Bitmap bmp = GetTheBitmap(); System.IO.MemoryStream stream = new System.IO.MemoryStream(); bmp.Save(stream, System.Drawing.Imaging.ImageFormat.Bmp); stream.Position = 0; byte[] data = new byte

Function for BMP color inverting doesn't work

牧云@^-^@ 提交于 2019-11-29 17:56:23
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, SEEK_SET); fputc(255 - old, fp); } fclose(fp); } Where am I mistaken? Adding an fseek into the loop