473,486 Members | 2,407 Online
Bytes | Software Development & Data Engineering Community
Create Post

Home Posts Topics Members FAQ

Image getting corrupt


Hi guys,
I am writing a imaging aplication on VC++.I have to display images and
apply effects onto it.Images could be of any type like
jpg,gif,bmp,psd...
I am using createDibSection API.it requires BITMAPINFO struc as one of
its parameters.Its working well(Images are successfully displayed) but
my problem is that in certain images(of any type)they are skewed and
becomes B/W(means Data corruption).U can see my code of populating
BITMAPINFO and CreateDibSection...Can any body help me in solving the
annoying probs.
[Note:If I am changing the dimension of image by few pixels using
photoshop resultant image is displayed well.]

BITMAPINFO bmi;

bmi.bmiHeader.biSize = sizeof(BITMAPINFOHEADER);
bmi.bmiHeader.biBitCount = 24; bmi.bmiHeader.biWidth
= swidth;//Image width
bmi.bmiHeader.biHeight = -sheight;//Image Height
bmi.bmiHeader.biPlanes = 1;
bmi.bmiHeader.biCompression =
BI_RGB; //uncompressed bmi.bmiHeader.biSizeImage =
0; bmi.bmiHeader.biXPelsPerMeter = 0;
bmi.bmiHeader.biYPelsPerMeter = 0;
bmi.bmiHeader.biClrUsed = 0;
bmi.bmiHeader.biClrImportant = 0;
bmi.bmiColors[0].rgbBlue = 0;
bmi.bmiColors[0].rgbRed = 0;
bmi.bmiColors[0].rgbGreen = 0;
bmi.bmiColors[0].rgbReserved = 0;
hBmp = CreateDIBSection( hdc_
, &bmi
, DIB_RGB_COLORS
, &imageBuff //pointerto created buf
, NULL
, 0);

dcMem = ::CreateCompatibleDC(hdc_);//creates a memory compatible
device context (DC)passing exixting DC
(HBITMAP) ::SelectObject(dcMem, hBmp); //selects handle of image
toDevice

--
apoorv
------------------------------------------------------------------------
Posted via http://www.codecomments.com
------------------------------------------------------------------------

Nov 17 '05 #1
1 1201
On Mon, 14 Feb 2005 09:47:52 -0600, apoorv
<ap***********@mail.codecomments.com> wrote:

Hi guys,
I am writing a imaging aplication on VC++.I have to display images and
apply effects onto it.Images could be of any type like
jpg,gif,bmp,psd...
I am using createDibSection API.it requires BITMAPINFO struc as one of
its parameters.Its working well(Images are successfully displayed) but
my problem is that in certain images(of any type)they are skewed and
becomes B/W(means Data corruption).U can see my code of populating
BITMAPINFO and CreateDibSection...Can any body help me in solving the
annoying probs.
[Note:If I am changing the dimension of image by few pixels using
photoshop resultant image is displayed well.]


Scan lines must be multiples of 4 bytes.

So, for a 3-pixel wide 24-bit BGR image, each scanline will be 12
bytes, the last 3 unused.

Here's an easy way to calculate the required width of a row for a
specific width and bits-per-pixel:

scanwid = (((width * bpp + 7) / 8) + 3) & ~3;

Of course, to create the number of bytes required for the image data,
you need to multiply this scanwid by the image height.

--
Sev
Nov 17 '05 #2

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

4
2743
by: Bjarte Andreassen | last post by:
Hi, I have a problem retreiving images from a MSSQL 2000 database with php. I wrote an ASP page using "response.binarywrite" to get the same image, and this worked 100%. Therefore, the images in...
303
17411
by: mike420 | last post by:
In the context of LATEX, some Pythonista asked what the big successes of Lisp were. I think there were at least three *big* successes. a. orbitz.com web site uses Lisp for algorithms, etc. b....
4
2291
by: moondaddy | last post by:
Using vb.net I need to download image files to the client browser where they can save to disk. Below is some sample code I'm using. when I run this the File Download window in the browser says: ...
35
2630
by: Stan Sainte-Rose | last post by:
Hi, What is the better way to save image into a database ? Just save the path into a field or save the image itself ? I have 20 000 images (~ 10/12 Ko per image ) to save. Stan
21
21235
by: cman | last post by:
does anyone know why i can't generate images with: header("Content-type:image/jpeg"); imagejpeg($img_number); i've tried different examples but i always get a text output as if the header...
6
1969
by: nichughes | last post by:
Hello all, A question relating to http://www.entrust-systems.net/ Just for a change I have run into a problem that seems to be OS specific rather than browser specific - the box image that is...
23
5862
by: Peter | last post by:
I have a problem with a page show_image.asp that returns a jpg image under Windows XP Pro SP2. The page sets content type as: Response.ContentType = "image/jpg" While this works perfectly fine...
7
4775
by: bookon | last post by:
I was running into the System.Drawing.Image.FromStream "parameter is not valid" on some of the images I was retrieving from a blob column in Sql Server. I thought there were corrupt images as...
8
2766
by: iheartvba | last post by:
Hi this is a query made using access query builder: SELECT tblBank.BankID, Now() AS TimeRecd, Val(Right(nz(,0),3)) AS ConsID, "AutoCASH" AS RecUser, tblBank.Dt, Forms!frmRecCASHRunningBal!tbGroup...
0
7100
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
6964
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
7330
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
0
5434
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...
1
4865
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new...
0
4559
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and...
0
3070
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The...
0
1378
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated ...
1
598
muto222
php
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.