png

常见图片格式详解

南楼画角 提交于 2019-12-25 02:58:20
做了几年有关图形、图像的工作,对图片格式算是小有经验,在此写成一文章总结下。虽然一开始并不想讲很理论的东西,但写完后发现几乎全是理论,细想一下关于图片格式的知识本身就是理论的东西,囧~~ 那就力求用最简单的方式将这些“理论”讲清楚吧。 常见的图片格式有bmp, jpg(jpeg), png, gif, webp等。 图像基本数据结构 要讲图片格式还先得从图像的基本数据结构说起。在计算机中, 图像是由一个个像素点组成,像素点就是颜色点,而颜色最简单的方式就是用RGB或RGBA表示, 如图所示 (图1) (图2) 如果有A通道就表明这个图像可以有透明效果。 R,G,B每个分量一般是用一个字节(8位)来表示,所以图(1)中每个像素大小就是3*8=24位图, 而图(2)中每个像素大小是4*8=32位。 这里有三点需要说明: 一、图像y方向正立或倒立 图像是二维数据,数据在内存中只能一维存储,二维转一维有不同的对应方式。比较常见的只有两种方式: 按像素“行排列”从上往下或者从下往上。 如图所示的图像有9个像素点,如果从上往下排列成一维数据是(123456789), 如果是从下往上排列则为(789456123)。 只所以会有这种区别是因为,前一种是以计算机图形学的屏幕坐标系为参考(右上为原点,y轴向下 ),而另后一种是以标准的数学坐标系为参考(右下为原点,y轴向上)。这两个坐标系只是y值不一样

Convert server response (std::string) into a png file

半腔热情 提交于 2019-12-25 02:16:34
问题 I'm getting a response from a server using boost::asio. The result is stored in a std::string. I want to convert this std::string into a .png image and write it to file. I'm having awful trouble with this. Here is my code: CURL *curl; CURLcode res; std::string errorBuffer[CURL_ERROR_SIZE]; std::string url="http://www.google.ie/images/srpr/logo3w.png"; std::string response=""; curl_easy_setopt(curl, CURLOPT_ERRORBUFFER, errorBuffer); curl_easy_setopt(curl, CURLOPT_URL, url.c_str()); curl_easy

Java/PNG upload to .php

痴心易碎 提交于 2019-12-25 01:26:05
问题 This is what the local .png file has when I edit it w/ notepad: http://i.stack.imgur.com/TjNGl.png This is what the uploaded .png file has when I edit it w/ notepad: http://i.stack.imgur.com/2tXgN.png Why is 'NUL' being replaced with '\0'? This makes the file corrupt and unusable. I use this java code to upload the local .png: public static byte[] imageToByte(File file) throws FileNotFoundException { FileInputStream fis = new FileInputStream(file); ByteArrayOutputStream bos = new

How to convert hexdump string of PNG data to binary in Python 3?

十年热恋 提交于 2019-12-24 19:48:17
问题 I have a hexdump string of a small PNG file that I want to convert to binary for writing out a PNG file: clip = "0x89 0x50 0x4e 0x47 0xd 0xa 0x1a 0xa 0x0 0x0 0x0 0xd 0x49 0x48 0x44 0x52 0x0 0x0 0x0 0x8 0x0 0x0 0x0 0x7 0x8 0x2 0x0 0x0 0x0 0xba 0x3b 0x9b 0x9 0x0 0x0 0x0 0x3 0x73 0x42 0x49 0x54 0x8 0x8 0x8 0xdb 0xe1 0x4f 0xe0 0x0 0x0 0x0 0x29 0x49 0x44 0x41 0x54 0x8 0x5b 0x63 0xfc 0xff 0xff 0x3f 0x3 0x36 0xc0 0x84 0x4d 0x10 0x24 0x46 0x2b 0x89 0xf7 0x1f 0xfe 0xfd 0xfc 0x9 0x75 0xb 0x8a 0x1d 0x39

Showing a PNG file with transparent background using javafx

半腔热情 提交于 2019-12-24 19:44:10
问题 Am actually working on a splash Screen unsing javaFX, everythink works fine but I want to show a png image with a transparent background on the splash screen, but am unable to do it, can someone please tell me if it's possible to do it from JavaFX Scene Builder or not ? 回答1: I'm in a bit of a rush, but below is a quick example to show you how it can be done by setting the StageStyle to Transparent and the scene fill to the color "transparent". @Override public void start(Stage aStage) throws

Pillow convert png to 8bit bitmap

放肆的年华 提交于 2019-12-24 19:19:11
问题 i tried to convert 8bit PNGs to 8bit(256indexed palette) Bitmap image, but Pillow is keep vomiting crappy outcome. this is what i tried. image = Image.open(file) image = image.convert('P') pp = image.getpalette() pp[0] = 255 pp[1] = 0 pp[2] = 255 image.putpalette(pp) or image = Image.open(file) image = image.convert('P') image.save(blabla.bmp) and this is the outcome what i expected to see. this is an actual bitmap(done by Photoshop.) Photoshop and this is what Pillow did: Pillow what kind of

How to save ggrough chart as .png

妖精的绣舞 提交于 2019-12-24 19:09:19
问题 Say that I am using the R package ggrough (https://xvrdm.github.io/ggrough/). I have this code (taken from that webpage): library(ggplot2) library(ggrough) count(mtcars, carb) %>% ggplot(aes(carb, n)) + geom_col() + labs(title="Number of cars by carburator count") + theme_grey(base_size = 16) -> p options <- list( Background=list(roughness=8), GeomCol=list(fill_style="zigzag", angle_noise=0.5, fill_weight=2)) I can then create the chart (I am using RStudio): get_rough_chart(p, options)

How do I insert a PNG comment block when saving an HTML5 canvas using javascript toDataURL?

依然范特西╮ 提交于 2019-12-24 18:27:59
问题 I have a compact canvas-to-png download saver function (see code below). This code works very well and I am satisfied with its output... mostly. Would a second replace suffice? What would that replace look like? My only other option is to post-process the file with imagemagick. Any ideas? More completely: I want to add metadata from javascript. I found this link http://dev.exiv2.org/projects/exiv2/wiki/The_Metadata_in_PNG_files which details the structures, and I may be able to figure it out

BitmapPalette Insufficient memory exception

谁说胖子不能爱 提交于 2019-12-24 18:05:11
问题 I have the following piece of code that runs in a loop. public void Test(Bitmap bmp) { FormatConvertedBitmap fBitmapSource = new FormatConvertedBitmap(); PngBitmapEncoder pngBitmapEncoder = new PngBitmapEncoder(); BitmapImage bi = new BitmapImage(); using (MemoryStream ms = new MemoryStream()) { bmp.Save(ms, ImageFormat.Png); bmp.Dispose(); bmp = null; bi.BeginInit(); bi.StreamSource = ms; bi.EndInit(); BitmapPalette pallete = new BitmapPalette(bi, 256); ... Last line BitmapPalette pallete =

R googleVis to png file

≯℡__Kan透↙ 提交于 2019-12-24 15:03:32
问题 I have the following code that works fine. I would like to know if it's possible to take this and export it as a png file. Anyone know of an easy way to do this. I'm just getting started in the R world so a noob. Here is my code library(RODBC) library(googleVis) con <- odbcConnect("Live", uid="Rxyzuser", pwd="xxxxx") attendees <- sqlQuery(con, "exec rpt_r_vis") regCal <- gvisCalendar(attendees, datevar="Reg_add_date", numvar="Counts", options=list( title = "Registrations per Day Heatmap",