bmp

How to convert png/jpeg to .bmp in iOS

对着背影说爱祢 提交于 2019-12-12 06:28:13
问题 How can I convert png/jpeg to a .bmp image? I have tried the following solution but no luck: CGImageRef sourceRef = source.CGImage; size_t width = CGImageGetWidth(sourceRef); size_t height = CGImageGetHeight(sourceRef); CGColorSpaceRef colorSpace = CGColorSpaceCreateDeviceRGB(); size_t bitsPerComponent = 8; size_t bytesPerPixel = 4; size_t bytesPerRow = (width * bitsPerComponent * bytesPerPixel + 7) / 8; size_t dataSize = bytesPerRow * height; unsigned char *data = malloc(dataSize); memset

C++ How to create a large bitmap from a datalist stored in a deque?

与世无争的帅哥 提交于 2019-12-12 04:38:27
问题 I am building my first ever program in C++ over and over again. The program is intended to create a picture, a gradient - with parameters of height h , width l , in pixels, and 4 parameters of density Da, Db, Dc, Dd . This gradient is produced by '1 bit' pixels: they are black or white - and by the simplest error-diffusion algorithm (so-called "naive" sometimes), >> push the error on the next pixel of the line. After having performed an optimization ( deque instead of vector allows bigger

Re: Get pixel data as array from UIImage/CGImage in swift

。_饼干妹妹 提交于 2019-12-12 03:36:17
问题 This code works for me (Swift 2 playground) in Gray scale, loading a colour .BMP image... Get pixel data as array from UIImage/CGImage in swift ... but if I change bytesPerPixel to 3 (or 4) and use let colorSpace = CGColorSpaceCreateDeviceRGB() ...the code still runs with no errors, but pixel values are all zeros. Any suggestions as to how to fix that? 回答1: You probably forgot the CGImageAlphaInfo parameter. For color images, if you assume bytesPerPixel to be 4, you need to set either RGBA

terminated by signal SIGSEGV in C

▼魔方 西西 提交于 2019-12-12 03:26:43
问题 I was writing a C program that reads the width and heights of a bmp image following (http://smsoftdev-solutions.blogspot.com.au/2014/07/code-for-reading-bmp-image-files.html). But I've met an error in terminal, it shows that: i './a.out' terminated by signal SIGSEGV (Address boundary error) I did some googling, they mention it's accessing extra memory problem, but I can't really find that in my code, any suggestion would be appreciated #include <stdio.h> struct __attribute__((__packed__))

int pixels array to bmp in java

試著忘記壹切 提交于 2019-12-12 02:25:49
问题 How do i create new bmp image in java from int array that contains pixels (from getPixel() of pixelGrabber class) ? Thanks 回答1: Make a BufferedImage and call setPixel. BufferedImage: http://download.oracle.com/javase/1.4.2/docs/api/java/awt/image/BufferedImage.html If you want BMP file then you can use ImageIO.write(bufferedImage,"BMP", new File("mybmp.bmp")); I would give you the link to ImageIO class but Stack Overflow is preventing me from spamming. 回答2: In Kotlin: // As it happens default

Write text on BITMAPINFO in memory

蓝咒 提交于 2019-12-11 18:17:59
问题 I retrieve a frame from a .avi video as BITMAPINFO and I want to write a string on it, and I dont want to use OpenCV.I could write a library which manually changes the pixel color from the image , to form letters, but it would take a lot of time. The image is 32 bits RGBA pbmi = (BITMAPINFO*)AVIStreamGetFrame(pgf, i); BYTE *pPixelSrc = (sizeof(BITMAPINFO) + (BYTE*)pbmi); long width,height; width = *((long*)(((BYTE*)pbmi)+4)); height = *((long*)(((BYTE*)pbmi)+8)); //Draw string on data

How can I read a BMP file and access its header info via a struct pointer without using #pragma pack or __atribute__((packed))?

被刻印的时光 ゝ 提交于 2019-12-11 14:59:37
问题 Here is my code. I would like to know how to "properly" read the BMP file and then read the header values without forcing the struct to be packed. typedef struct __attribute__((packed)){ uint8_t magic[2]; /* the magic number used to identify the BMP file: 0x42 0x4D (Hex code points for B and M). The following entries are possible: BM - Windows 3.1x, 95, NT, ... etc BA - OS/2 Bitmap Array CI - OS/2 Color Icon CP - OS/2 Color Pointer IC - OS/2 Icon PT - OS/2 Pointer. */ uint32_t filesz; /* the

read a .bmp image using od command

南楼画角 提交于 2019-12-11 14:53:03
问题 I have an image (grayscale image .bmp) . that I am trying to read.So, I used the imread() function using matlab and python and I get the same results. the image /* with Matlab */ 109 107 104 101 96 91 87 84 76 75 75 77 78 80 80 80 81 78 77 75 74 72 68 68 69 71 72 73 75 76 77 78 73 73 72 70 69 68 67 67 67 68 69 71 72 74 75 76 ... /* with python in an rgb form */ [[[109 109 109] [107 107 107] [104 104 104] .... you can see that it is the same interpretation. But when I use the following command

android sending bmp using sockets

橙三吉。 提交于 2019-12-11 14:15:55
问题 I'm trying to send bmp image using socket. I have such code on android: ByteArrayOutputStream stream = new ByteArrayOutputStream(); MainActivity.bmp.compress(Bitmap.CompressFormat.JPEG, 20, stream); byte[] byteArray = stream.toByteArray(); OutputStream os = echoSocket.getOutputStream(); os.write(byteArray,0,byteArray.length); os.flush(); and on PC: InputStream in_ = clientSocket.getInputStream(); OutputStream out_ = new FileOutputStream("filename.bmp"); final byte[] buffer = new byte[1024];

Win32 Unable to add custom toolbar icon having transparency

允我心安 提交于 2019-12-11 11:29:11
问题 I am using this code to add a toolbar to the window with one button having a custom image: HWND hToolbar = CreateWindow(TOOLBARCLASSNAME, NULL,WS_CHILD | TBSTYLE_FLAT|TBSTYLE_AUTOSIZE |TBSTYLE_LIST|CCS_BOTTOM, 0, 0, 0, 0, hwnd, NULL, ghInstance, NULL); //create the toolbar SendMessage(hToolbar, WM_SETFONT, (WPARAM)hFontBold, static_cast<LPARAM>(MAKELONG(TRUE, 0))); //set the font. there cannot be the problem //↓↓↓↓↓**ILC_COLOR32 is specificied here but 32bit bmp is still not showing**// auto