image,bitmap,png,decode , Decode image to bitmap ok, but why?

Decode image to bitmap ok, but why?


Tag: image,bitmap,png,decode

I would like to know why we need to decode let's say a png to a bitmap in order to show the image. Why not just show the png like that (encoded).

I'm asking here a moron type of question on purpose. It's clear to me it's impossible to show an encoded image just like that but I want to know why, and how an image is shown on a screen because it's easy just to do :

canvas.drawBitmap(((AndroidImage)Image).bitmap, x, y, null);

I want to understand the full of it. I'm guessing we need to show every pixels one by one, but I want more details.

It's easy to know how to do, it's a bit harder to understand why.

If someone has a course/tuto/article/explanation that explains it... I would appreciate

Thanks in advance

PS : Please don't respond "you need to decode/convert png to bitmap" I know that... And that's not my question


There are lots of reasons. There is not really a direct relation between 'a value in a file' and 'a pixel on a screen'.

  1. You need to know the width and height of the bitmap. You cannot infer this from the image size -- it has to be stored somewhere inside the image file. (Or anywhere else. Point is, you have to know its size.)
  2. You need to know the bit depth and color model of the bitmap. You cannot meaningfully copy an 8-bit indexed image directly onto a screen that accepts 32-bit BGR ordering with an unused byte, for example.
  3. Your example, the PNG file format, specifies that all image data is compressed. This is for a sane reason: the PNG format was designed for use on web pages, in a time period where every byte still counted. But even the lowly simple BMP file format uses a very specific form of 'encoding': in its 24-bit format, every line consists of sets of BGR values for each pixel and is padded at the end with enough bytes to make its total length evenly divisible by 4.
  4. JPEG uses an even more advanced encoding scheme (which is too difficult to explain in a few short words) so it can compress images even more. The advanced encoding scheme allows far more compression than regular methods (which in turn means there is only the tiniest relation between 'values in the file' and 'pixels on the screen').


Windows Phone 8.1 get image from base64 string

How can i get an Image from a base64 string on Windows Phone 8.1? I know how to decode the image if that helps? var imageBytes = Convert.FromBase64String(base64StringWithImageData); var ms = new MemoryStream(imageBytes, 0, imageBytes.Length); var decoder = await BitmapDecoder.CreateAsync(BitmapDecoder.PngDecoderId, ms.AsRandomAccessStream()); But nowhere have i found how i can get...

Bandpass Filter in Python for Image Processing

I have a noisy dataset (a stack of images) which films dim particles moving about some really bright artefacts (which are immobilized). I would like to somehow remove the immobilized artefacts from the images by applying some sort of bandpass filter wherein only pixels within a specific range are converted...

draw darkened bufferedimage without touching it

I'm currently making a tile-based strategy game, with its map made of a bunch of sprites (BufferedImages), drawn by java.awt.Graphics.drawimage(..) What i want is to be able to draw those sprites a tone darker if the player is too far away from them. I've seen a lot of similar questions...

Create a border around image when active/clicked

I want to let my website visitors select from 3 different images and what I want now is a border around the image when they selected, so basically when it's active. I hope it's understandable what I am looking for. Can someone help me perhaps with that? I've tried to...

Is there a way to make images take up less space in an apk or will I have to use an APK expansion file? [closed]

I made an app in android studio that has a lot of images, making the app exceed the 50MB limit. I do not fully understand how to make an expansion file so I want to try to avoid it. I copied all the images in each mipmap, can I get...

PHP How to not cache generated HTML but cache static data like images/js/css

Many PHP developers add the no-cache header on top of their PHP pages, so do I, for obvious reasons. Since PHP generated content is usually dynamic, having the browser cache them results in outdated data being presented to the user. To avoid this caching is usually disabled. <?php //no cache...

How to prevent exceeding matrix dimensions while dividing an image into blocks?

I have an image which I want to divide into overlapping blocks. I have set the box to be of size 8 rows and 8 columns, and the overlapping factor to be 4 rows/columns. This is what I have written to solve this: img = imread('a03-017-05.png'); overlap = 4 count...

Android: int array set null but still in memory after GC

I tried to break it down to the main code regarding the pix array: public class BitmapProcessor { int[] pix; public Bitmap run(Bitmap b) { pix = new int[picw * pich]; bitmap.getPixels(pix, 0, picw, 0, 0, picw, pich); // do some stuff bm = Bitmap.createBitmap(picw, pich, Bitmap.Config.ARGB_8888); bm.setPixels(pix, 0, picw,...

Preload image for seamless background image change in JavaScript

I have a Python websocket application which sends an image path to a JavaScript HTML file. When the image path is received, I change the background image of the webpage to the supplied image. The issue I'm having at the moment, is when the background changes from the old image...

Uploading PNG to Website Server

I have seen loads of other topics and I've tried them all. Can someone please help with why this script won't upload PNG files? Blank PNG image being displayed. $image = $_FILES['file']['tmp_name']; $image_name = $_FILES['file']['name']; $ext = pathinfo($image_name, PATHINFO_EXTENSION); $location = "Profiles/{$user}/Picture/{$image_name}"; $new_image = imagecreatetruecolor(100, 100); $source_image = imagecreatefrompng($image); imagealphablending($source_image,...

Fetch a saved image and display

I am developing an App in which I have stored images through imagePicker. now i want to display same images in my collectionView. I got response as a path path=assets/image/155/155_557b1259b8a51.jpg when i add then it shows error. How can i get the images through this path.Please Help me out....

Getting an image to render with php

To keep it simple, I'm trying to display an image using php to help try and prevent any kind of a security loophole. I have the image being read through a php script and I am wanting to render it, so instead of going to I want to have...

Import java package from Matlab deploytool to Android Studio App

I managed to create a java package from a Matlab function (for image processing) using deploytool. I tested it in Eclipse and it runs perfectly. The problem is that I want to use this Matlab function for an Android Studio project and I can´t find any way to make it...

How to search images by name inside a folder?

I have a MySQL table with a column "rounds" and each "rounds" has his own photos. Exemple round1 has photos from start=380 end=385. This means it has 6 photos and the name of the photos contains 380,381,382,383,384 or 385 inside. I use this PHP code to display the photos from...

How can I put a device-independent bitmap into the Windows clipboard using just direct WinAPI? (No MFC or other wrappers)

I've been trying to get this to work for awhile now, but I can't seem to figure it out, and hours of Googling has yet to reveal any useful results. I have an array of 32-bit pixels in RGBA order, and I want to create a device-independent bitmap from them...

Saving images with more than 8 bits per pixel in matlab

I need to save a set of pre-processing images in matlab, resulting in grayscale images. The problem is the fact that these pre-processed images have pixel values higher than 255. If I save them with imwrite() as, for instance, .PNG files, does matlab normalize the values to be in [0,255]...

Loading images into html5 canvas

I am using nodejs sails for my app. The app is going to use 50-100 images at some points. I was wondering if someone can point pro and cons of using /assests/images/ folder vs outside repository i.e. AWS S3 for image storing and pulling to draw on the canvas.

Captcha with merging a number with real image

I have searched for captcha generation tools, but I could not find any tool which can generate the below captcha pictures. You can seen these when you want to register on google. It uses a number merged on a real picture and produce a new real image picture. Do you...

why images in the Images.xcassets are not displayed?

There are some image resources in my Images.xcassets. Recently they cannot be displayed in the app when testing in the iPhone/iPad devices. I guess they are not copied to the Bundle when build and package. Then i check the Copy Bundle Resources in Build Phases. The Images.xcassets is in here....

adding link_to with image_tag and image path both

I am trying to replace the tag with link_to in my rails application view. for replacing I have svg icon, text and link all in one tag. Here is below <a class="navbar-brand" href="index.html"><%= image_tag 'logo.svg', "data-svg-fallback" => image_path('logo.svg'), :align=> "left" ,:style => "padding-right: 5px;" %> My Project </a> but I...

Excel VBA 2013 Print Image

I would like to print an image that shows in a frame on a userform. frame1.Picture = LoadPicture(spath & xPicture & ".jpg") spath is the full path to where the picture is stored. This shows the picture just fine. Now I would like to be able to print it. Is...

Python Resize Multiple images ask user to continue

I'm trying to make a script that resize multiple or a single image based on a data pulled from XML. My question is if i have multiple images how can I print out a qusetion like "There are more than 1 image do you wish to resize image 2 also?......

Images not loaded from master page in directory,image
I will make a website whit ASP.NET using C# on the background. I have make my master page with the following image: <img src="afbeeldingen/berichten.png" alt="new messages" /> Because I have a lot of pages in my site, I have make directories in my solution. My problem is now when I...

what is the nodejs package for s3 image upload

I'm looking to upload my assets to s3. Is there any package in Nodejs like carrierwave in rails I want to resize images with versions. I have come across papercut. What is the best node module for s3 image upload....

Dynamically resize side-by-side images with different dimensions to the same height

I have two images side-by-side within a block-level container with arbitrarily different dimensions (as in, they could be any two images) that I want to dynamically adjust the width of so that the overall height of the two images is the same. I don't think this can be done in...

making an image exactly circular without borders

I want a circular image for my Profile activity. I have already tried these answers but it does n't work in my case. Create a circular image view in Android How to make an ImageView with rounded corners How to make an image fit into a circular frame in android...

How to convert an Image to Mat Android

I need to process Image for my Application. I get the Images for ImageReader. reader.setOnImageAvailableListener(new ImageReader.OnImageAvailableListener() { @Override public void onImageAvailable(ImageReader reader) { Image mImage = reader.acquireNextImage(); //mImage to Mat here mImage.close(); } },null); But now, I need to convert those images in Mat. I know that I can pass...

out of memory Error Unsolved

I am taking the image from internal memory.and pasting it on the greator image in the merge function.after the 66 image the app is crashing badly and the error is out of memory . Do you have any idea why the app crashing and how to solve the app...

Make element fill rest of div without resizing Image

I want the Logo Image in this nav-bar to fill its height while still retaining its aspect ratio. The remaining width should be filled by the ul element. As long as the ul elements width is not 100% the image is displayed correctly. How can I do that? The...

Verify data integrity for varbinary column

I am inserting a .jpg into a varbinary(max) column in SQL Server 2012 using the following command: INSERT INTO Employees VALUES(5, (SELECT * FROM OPENROWSET(BULK N'C:\4.jpg',SINGLE_BLOB) AS image)) It inserts a record in the table. Then I used the following command to restore the file from db to file system....

How to resolve Out of Memory Error on Bitmap in Android?

I want to set an image in image view,I am retrieving the image path in my first activity and I am passing it via intent as a String to second activity.In the second activity I set the path to an image view,It is working properly , and I need to...

How to resize image according from screen resolution on html css

I want to change an image so that its size is according to the screen resolution, for example 1920x1080 to 1600x900, using HTML and CSS. How can I do it?...

How to crop image from center using wp_image_editor

I am working on WordPress plugin. In plugin the user upload images from meta field and in back end i use wp_image_editor for cropping and re sizing the images. The images re sized very well but on cropping the images not cropped very well. I give x-dimension 100 and y-dimension...

Java encode raw bytes into image simple image fomat/ file

I am very new to image encoding and would rather not learn a whole lot about it. Basically I'm taking greyscale byte array where each byte equals one pixel. I'm getting this data from mnist where I get 28x28 byte images. Anyway, bellow is my code, so you understand what...

JNI C++ to Java 32 bit image not showing properly

I have the following C++ code for JNI And the following Java code to create a 32bit bufferedimage, the sizes are also received through JNI Everything seems to work only that I have some weird colors in the image and I don't know how to get it right Result of...

Can't get images from storage laravel 5

Hey so i'm trying to put my images into a slideshow i have on my index. the images are saved on storage/app , and then the rest of the path i retrive from my database. I managed to output the correct path on the <img src> tag, and the title...

image.Decode results in “unknown format” when source is multipart.File

I have a multipart.File that a user uploads to my server, and then I take that file and upload it to s3 using aws-sdk-go, but I also want to create a thumbnail of that image. The code below works fine in my tests when I file is the return value...

winapi: from HDC to an HBITMAP

I would like to do something which I believe is fairly simple but since I am new to the winapi I am finding a lot of problems. Basically I have an HDC (which I am BitBlitting from a loaded Bitmap) and I am drawing a rectangle on it. Then I...

I can't download images uploaded ​​with “move_uploaded_file()” code on filezilla

When I use move_uploaded_file() code everything works fine and my files are being moved to my server. But later if I want to download those files from my server using filezilla, it says: "Could not start the transfer process" But i can download other files crate with imagejpeg() code. So...

Change Background image in WPF using C# [duplicate]

This question already has an answer here: Change WPF window background image in C# code 3 answers I'd like to change the background image of my WPF application by a button. I know how to do it using WindowsForms, but in WPF I failed. I found a solution already,...

Crop does not work for gallery images

I am using the following code to crop images from camera and gallery : private void doCrop() { final ArrayList<CropOption> cropOptions = new ArrayList<CropOption>(); Intent intent = new Intent(""); intent.setType("image/*"); List<ResolveInfo> list = getPackageManager().queryIntentActivities(intent, 0); int size = list.size(); if (size == 0) { Toast.makeText(this, getApplicationContext().getString(R.string.crop_unavailable), Toast.LENGTH_SHORT).show(); // return }...

Create mask from bwtraceboundary in Matlab

I'm trying to create a mask (or similar result) in order to erase pieces of a binary image that are not attached to the object surrounded by the boundary. I saw this thread ( to do this from bwboundaries, but I'm having trouble making suitable changes to it. My goal...

Better image normalization with numpy

I already achieved the goal described in the title but I was wondering if there was a more efficient (or generally better) way to do it. First of all let me introduce the problem. I have a set of images of different sizes but with a width/height ratio less than...

Using raphael.js to draw an image with parameters sent through

This is what I have tried so far. socket-server.js var app = require('express')(); var http = require('http').Server(app); var io = require('')(http); var config = require('./config2.js'); app.get('/', function(req, res){ res.sendfile('socket-client.html'); }); io.on("connection", function (socket) { var mapRes = {width : 720, height: 1040}; socket.emit("mapRes", mapRes); }); http.listen(3000, function(){ console.log('listening on *:3000');...

Best Solution for Bootstrap Carousel Image Size Changes Causing Elements on Page to Move

I have an image carousel on my site's homepage, and sometimes a few of the images have slightly higher height and width. This causes the page elements, such as a list of test items below the carousel, to move around as each image in the carousel changes. What is the...

How to make a Javafx Image Crop App

I am building an application for my colleagues to crop image. I use FXML with Scene Builder to build the GUI. The user click a button to choose a image from his computer. Then, the image is shown in the GUI. User can zoom and move in the pane. At...

Paste pivot table as bitmap into Body of Outlook Appointment

Using Excel VBA, I'd like to make a small pivot table visible to Outlook users. I do NOT want to paste into a message body I DO want to paste into an appointmentItem Here is my code that creates the Appointment and copies Range to clipboard. How do I paste...

Upload image to server from gallary or camera android

i have a Activity for Upload image from gallary or camera to server.image upload from camera is fine but upload from gallary is not done.i have a error showing BitmapFactory﹕ Unable to decode stream: FileNotFoundException i want to do when i pick up the image from gallary it is shown...

Trouble generating Barcode using ZXing library with large data

I need to generate barcode in 128A format with data: 900000588548001100001305000000000207201512345.6|12345.7 I'm using ZXing library and Here is my method: private void barcodeGenerator(String data) { try { writer = new MultiFormatWriter(); BitMatrix bm = writer.encode(data, BarcodeFormat.CODE_128, 700, 200); Bitmap ImageBitmap = Bitmap.createBitmap(700, 200, Config.ARGB_8888); for (int i = 0;...