How Do You Convert An Image Size To Pixels?
I need to resize an Image object and I've got a procedure that I think will do it (using GDI).
My problem is that my Image object can be scaled in either cm, mm or inches.
I need to know it's size in pixels to use the procedure.
Is there an easy way to work this out?
View Complete Forum Thread with Replies
See Related Forum Messages: Follow the Links Below to View Complete Thread
Image Size (PictureBox) In PIXELS?!
Ok i'm loading an image into a picture box with bleh.picture=loadpicture(path)...nothing fancy..
i am trying to get the height and width in PIXELS of the image that was loaded. I swear ive tried everything and nothing returns the correct value! Help?
User Scale To Pixels: How To Exactly Convert?
In graphics programming, if I want to use API functions then I must often convert coordinates from my own coordinate system to pixels and viceversa. I have found very small differences (about 1 or maybe 2 pixels) in the expected vs actual plotted positions and I think this is probably due to mishandling coordinate transformations involving integers (pixels).
Namely -considering only the horizontal coordinates, vertical would be similar- if I have a picturebox having an inner width (i.e. excluding the borders) of ScaleWidth, then the pixel coordinates run from column 0 to column ScaleWidth-1. So far so good. If my user scale goes from, say, User1 to User2, I have used this formula for calculating pixels from user coordinates:
Pixel = (ScaleWidth - 1) * (User - User1) / (User2 - User1)
This assumes the width of the plotting area in pixels is ScaleWidth - 1, not ScaleWidth. In other words, I assume User1 and User2 are exactly at the middle of the first and last pixels respectively.
My doubt is where should I count user1 and User2 from, i.e. which of the lines in the attached file (representing a simplified picturebox of 2 x 2 pixels) is correct.
I know there'll be discrepancies due to roundoff but I want the roundoff to be the same at the left and right sides of the plotted figure.
How Can I Convert Inches To Pixels -- Accurately?
Is this even possible? I want to display a "page" (it can have any height and width, but for now let's go with the regular old 8.5 x 11).
I used CurrentAutoScaleDimensions.Height to get the dpi of my monitor (96, according to the msgbox). Then I multiplied my page width and height (in inches) by the dpi to get the pixels.
It's close, but it's about 1.5 inches too big in both directions.
I googled about this topic and come across "twips" which sound like the solution...except they're gone in VB.NET.
Form Size In Pixels?
Is there a way that I can set form size units to pixels rather than twips? I hate working with twips because they are meaningless to me.. Pixels give me a much better idea of the size..
Pixels And Printer Resolution/size
i am using a control which has got printing capabilities. You need to set the printer resolution in pixels for it in order to get the print at the right size. It there some way i can calculate it?
We are using an HP4000 printer and we are printing on A4 paper. At the moment i have set the resolution through testing and it is set a 1000x6000. But ofcourse this wil only work for this printer. Anybody got some clues on how to calculate it from the printer object?
Command Buttons And Its Size In Pixels
i have to use a picture as a caption in some buttons and this image must be created outside of VB. to do that i need the size in pixels, not in twips.
i know that there's a formula to convert units, but isn't there any possibility to know it directly from VB?
i can know the size of a form in pix changing scale mode property, but this property isn't on cmd buttons
Edited by - xadap on 10/17/2005 9:50:01 AM
Converting An Area From VB's Native Size Units To Pixels?
anyone know how to convert an area from VB's native size units to pixels?
example: lets say i have a 4000 by 4000 (this changes) area. i need to find (relative to my mouse X and Y to the form) where im clicking on a 48x48 pixel grid. (the mouse uses the same measurements, doesnt it?) and the form will not always be maximised, which dosent help things.
Pixels In An Image!
I have a picture box in VB and what I want is when I click somewere on the image, I want a message box to pop up showing the RGB value of whatever colour i click on in the image!
If I click on a red part, then msg box says "RBG: 255,0,0" etc....
Any info?? I think someone mentioned using GetPixel?
Get Pixels From Image
I want to operate on images pixels. I use Picture Box which is my source of data by .Pixel(x,y). The problem is that it has to be visible in the x,y otherwise rgb -1,0,0 are given back.
Image To Pixels....
I have an Image control.. How do I determine the Size of the image loaded in pixels....
ScaleX(imgIcon.Picture.Width, vbTwips, vbPixels)
ScaleY(imgIcon.Picture.Height, vbTwips, vbPixels)
but its coming out with 22.9 (I know the image is 13x13)
Get Transparency Pixels In A GIF Or PNG Image
Hi guys, how could i get the "transparency information" in a gif or png image? The target would be an array of boolean that says if a pixel is transparent or not.
Thanks in advance
Getting Transparent Pixels From A Png Image
Hi. Basically, I'm trying to take a png image and determine which pixels in the image are transparent. The program would do a one time run through each pixel in the png to figure out where relevent image data is located. The idea is to use this information to intuitivly crop certain parts of the image for use in another part of the application. Using the GetPixel api and the picturebox point method do not work correctly as they cannot tell me when a pixel has a transparent value.
I suppose the only solution would involve reading data out of the actual png file, but I don't know where to begin in regards to this.
Since I'm using DirectX8 to render the images, i was wondering if there is a way to get this information from a dx8 device, texture or surfacedescription.
Thanks for the help.
Writing Pixels To Image In CE (using VB6)
I am writing a program in VB6 and want to write directly to an imagebox or picturebox somehow. I posted this in http://www.vbforums.com/showthread.php?t=444408 about a week ago and there has been (1) NO activity at all in that forum since and (2) no reply so I thought I'd bring it here. Seeing as I'm writing in VB6 I guess it could be considered classic VB (and what could be more classic VB than CE :-))
Anyway, here's the post I made back then, copied word for word:
"I am writing software in Windows CE for my Win Mobile 5 handheld PC. The reason why I am using CE is I have very little (next to none) experience in .NET and I feel more comfortable writing in a VB6 environment (and I have a CE development system installed to allow me to do this in VB6).
A piece of code I am writing displays a map on-screen (taken from streetmap) in an image box. It loads a BMP file (seems CE items can only load BMP or even less efficient image formats) and displays it in the image box which I will then use for navigation (not through a GPS system...I'm not writing that sort of program). I want to then read in the values of specific pixels within that image and perform a filter on the pixel and re-draw it on the image...I basically want to highlight specific streets and will have co-ordinate data on each street in the program.
Has anyone got suggestions on how I would be able to manipulate pixels in an image like that?
Another aspect of this program I am working on is a more efficient way to store map-style images by reducing the number of colours...in theory I could get the maps I am displaying into about 5k or so...I'm looking for a method that could manipulate an image fast enough in CE, but the priority here is the above (editing specific pixels rather than the whole image :-))"
Getting Black Pixels In An IMAGE
i am trying to get only the black pixels in a black&white picture.
i found this code on the internet and tried to make it work.
but in the end it always answers 0 black pixels found.
here is the code:
Declare Function GetPixel Lib "gdi32" (ByVal hdc As Long, ByVal x As Long, _
ByVal y As Long) As Long
'The subroutine below counts the number of a given color in a PictureBox control:
Function CountPixels(color As Long, picBox As PictureBox) As Long
' PictureBox's ScaleMode
' must be set to 3 - Pixels
Dim x As Long, y As Long
Dim handle As Long, count As Long
' cache form's hDC property
handle = picBox.hdc
For y = 0 To picBox.ScaleHeight - 1
For x = 0 To picBox.ScaleWidth - 1
If GetPixel(handle, x, y) = color Then
count = count + 1
CountPixels = count
Dim blackPixels As Long
blackPixels = CountPixels(vbBlack, PictureBox1)
MsgBox "Number of black pixels: " & blackPixels
Find Pixels Of Image
i have an picture in c: named test.jpg.. is there anyway i can find out if it is 1000X1000 pixels or 500X400 pixels. i want i to be returned as text..
Read The Pixels Of An Image
I m trying to read the pixels of a monochrme image
i created an Image control and loaded it with a BMP file that I had
and did this based on clicking on a PB control
For row = 0 To 144
For col = 0 To 288
PSet (col, row), 0
i know the BMP's pixels are 288 x 144 cos pbrush of windows haircross tells me so
but what i dont understand is the size of the image that this BMP contains is (width 7 height) in proprties panel is something like 4120, 2160 pixels
whats going on ?
Resize A Jpeg Image To 100 X 100 Pixels
i have a program that saves data to a text file and a picture as a bitmap when the save button is clicked but before i can load the picture into the picbox i have to resize it to 100x100 using another pice of software. How would i resize my image when it is loaded to 100x100 (the source image is quite large as it is from a digital camera)
thanks in advance................ RedAngel
To Get Data Pixels From Image To MASM
My programm can load pictures in VB.... What I want to do is filtering a person from a blue background, then I want to paste this filtered image above a picture of a wheatercard.
The filter proces will I do in MASM, but first I need to know how I can get the data of the pixels (the color information) from the image from VB into MASM.
I hope someone can help me solving this problem
Calculating Total Black Pixels In An Image
this is the algorithm for calculating black pixels and then finding them recursively in the image...how do i change it into a VB program?
//tests if a pixel is black
bool IsBlack(int row, int col, LPVOID BaseAddress)
//a pixel’s RGB val is returned
COLORREF* pPixel = ((COLORREF*) BaseAddress) + row * 640;
COLORREF curPixel = pPixel[col];
BYTE red = GetRValue(curPixel);
BYTE blue = GetBValue(curPixel);
BYTE green = GetGValue(curPixel);
int black = 150; //RGB value to determine if Pixel is Black
//returns black if RGB vals < highest acceptable black val
if (red < black && blue < black && green < black)
/*Checks the above pixel if it is black and unmarked, if it is then the pixel is flagged */
/*into the Points structure and the MapPattern function is run with the above pixel */
/*as the parameter*/
if (Field[row–1][col] = black AND Points[row–1][col] != 1)
Points[row – 1][col] = 1
MapPattern(row – 1, col)
/* The same process checks the pixel beneath the input
location (note the statement checks if the pixel is pre-
existing before reentering the recursion*/
if (Field[row+1][col] = black AND Points[row+1][col] != 1)
Points[row + 1][col] = 1
MapPattern(row + 1, col)
/*Checking the pixel left*/
if (Field[row][col–1] = black AND Points[row][col–1] != 1)
Points[row][col – 1] = 1
MapPattern(row, col – 1)
/*Checking the right pixel*/
if (Field[row][col+1] = black AND Points[row][col+1] != 1)
Points[row][col + 1] = 1
MapPattern(row, col + 1)
Calculating Number Of Black And Red Pixels In A Image
hi..can anyone help me with the code to count the number of red and black pixels in an image? Pls reply as soon as possible. Really appreciate it
this is the algorithm for calculating black pixels and then finding them recursively in the image...how do i put it into VB?
//tests if a pixel is black
Flipping A Picture (GIF) With Transparent Pixels In Image Control
Before I say that it's impossible to do, I wanted to be sure.
I will closely describe my goal, first:
loading an Image control with a GIF file with transparency results in an object that is transparent in some areas, though it still responds to mouse clicks on these areas. A picturebox, however, does not allow this feature.
I want to have an image with its own picture flipped, without losing the transparency features. Is it possible?
(Please only let me know if it is impossible, I am not interested in doing a workaround at this time.)
I already tested BitBlt. It loses the transparency information.
Image Box, Thumbnail And How To Open Form Pixels And Twips
how do i make it so when a user clicks on a thumbnailed image, it opens a new form as big as the width and height of the image.
i have the width and height that i read from a database but the form opens in twips and not in pixels????
File System Object To Find Image Width In Pixels Or Twips
is it possible to use the FSO to get an imaages
width and height?
I have a MDI child form and i need to resize
it to the size of any given image.
i thought maybe i could use the
file system object but i'm not sure if you can
get these propertys w/ it.
any suggestions on how to resize my form to
the width of an image are appreciated.
How To Convert A Monochrome Image To A Pseudo Colored Image?
I need some help here. I have some monochrome (grayscale) images (.bmp format) here and i need to convert them into pseudo colored images making use of a lookup table (LUT).
What's going on here is:
I have some images that have just been captured by an IR Camera. To make these hotspots more visible to the user, I need to match certain temperature higher than a certain threshold to a color say Red.
Since the image is monochrome, the image will consists of the pixel values and not temperature information right? (or is it that this pixel values/intensities of the thermal image are the temperature information?)
So now, how do I create a LUT to match the temperature to a certain pixel value? I am rather confused with this temperature, pixel value and color concept. Can someone help me with this?
Can someone guide me with this conversion of monochrome image to a pseudo colored image? I am stucked here for quite a while now. Your help will be greatly appreciated
Thanks alot guys.....
Zooming Various Size Image To Fixed PictureBox Without Changing The Image Ratio
Yup!I need to scale different size image into a fixed picturebox. Without changing the image height vs width ratio.any of you can help me? thanks.
1)scale the image as big as possible depending the fixed picture box height or width.
I use the loadpicture function in loading picture.
If I use the image control, I found the stretch function will cause the image height and width ratio change.
How To Size The Image With Picture Box Size?
I use ADO and view the image on the picturebox ("Picture2").Why the image display on the picture box don't have same size with my picturebox?How to make the image display have same size with my picturebox.
Picture2.Picture = LoadPicture(Pesttable.Fields("PICTURE"))
Image Size To Picturebox Size
how can i make an image the same size as that of the picturebox displaying it.
i.e. stretching it accross the picturebox no matter how small or how big, just stretch it.
Size Window To Image Size
If I load a picture in to a picture box which is in turn on a form, how can I resize the form to the size of the picture once the picture has loaded?
Conforming Image Size To Picturebox, Not Picturebox To Image Size.
Hello all, i am taking a VB course (Using VB 6) and have run into a little problem.
I need (or want) to have it so users are viewing like... a gallery of the images, on each command button in my frame i have the code
Code: picturebox.picture = loadimage ("imagepath")
(ive run into the issue of running it on another machine and the images not appearing but thats a seperate issue, a seperate topic if i need it eventually)
what ive been able to do is use
picturebox.autosize = true
to make the picture box the size of the image, but thats 4 times as big as the original box and twice as big as my program window (frame?)
ive also tried .scalehight/width but i couldnt get any change with that.
ive searched multiple forums and couldnt find an answer, any help?
thanks in advance
How Do I Convert BMP Image To JPG Image(not A File)
I want to convert a picture image (that comes from my webcam) to a JPG image before sending the image as a byte array via LAN to an image box in another computer (not a FILE).
I want JPG because it is much smaller and quicker.
All the DLL's I have found only save it as a file which is no good to me.
Maybe there is a 2 step way of creating a 'virtual file' using Filescripting?
Or I could use a ramdisk and immediately read it to a pic box but that is cludgy.
I would much rather be able to CONVERT straight to a JPG IMAGE before sending.
Image Size From Image Control...
Hi, I wrote a simple app that loads an jpg image in an image control, but I need to know what the width and height of the image are... the imagecontrol is set on strectch = true.
Any help would be appreciated.
How To Convert 24-bit To 8-bit Bmp Image ?
I'm working with 24-bit image.
After converting to grayscale (pixel by pixel), I use savepicture() function to save bmp file. But the image is three times bigger than should be, cause the image is 24-bit, despite has only 256 grayscale...
That's why I need a source code to convert 24-bit dib to 8-bit dib.
Someone could help me ?
How Can I Convert An Image From 24 Bit To 16 Bit
How can i convert an image from 24 bit to 16 bit
I am developing an application in vb in which i had to transfer images from a client system to the server. I need to convert these images from 24 bit to 16 bit pixels. Can anyone help me in doing this ? I need some method to do this or a sample code. Also I would like to know if this can be done without dll files.
Any kind of help is highly appreciable.
sorry to anyone who looked at my last thread it was all over the place
this i hope is more straight forward
I have a simple program to convert an image in a picture box into as grayscale image ,from what i have been told it is possible to then change that image in to a black and white image with certain levels of gray being converted to black and lower levels of gray being converted into white how would i do this
here is my code to change into gray scale
what would i need to add to this code
Private Sub cmdGray_Click()
Pic.ScaleMode = vbPixels
X = Pic.ScaleWidth
y = Pic.ScaleHeight
For i = 0 To y - 1
For j = 0 To X - 1
pixel = Pic.Point(j, i)
red = pixel Mod 256
green = ((pixel And &HFF00) / 256&) Mod 256&
blue = (pixel And &HFF0000) / 65536
gs = ((red * 30) + (green * 59) + (blue * 11)) / 100
Pic.PSet (j, i), RGB(gs, gs, gs)
Pic.ScaleMode = vbTwips
does anyone know a tool or vb program/ocx wich permits to convert 24 bits colors BMP image to 256 gray level one ? ..or guideline to do this ...
Thanks a lot,
Convert Text To Image
Is it possible to code a program that converts text into images (gif) and the other way around? 1 pixel for each ASCII-value. For example giving all 255 types of green the values a,b,c,...,?,!,... ? A sort of coder-decoder.
I planned to rewrite a ascii-generator, but they work totally different..