473,626 Members | 3,427 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

BMP image to uncompressed PDF stream code fix

In:

http://groups.google.com/group/comp....3dcf952fc3e3d3

I said:

'-----
In:

http://groups.google.com/group/comp..../msg/c368352c1...

I posted VBA code for obtaining the pixel information from a BMP image
for use in PDF documents created directly from Access. I discovered
that the carry locations for the pixel sizes are incorrect. When the H

or W of the image is 256 or more the technique shown for reading the
values from the BMP file directly will produce values that are too
small. I suspect that bytes 20 and 24 should be used instead of bytes
21 and 25 for this case but I have not tested it. As a temporary
workaround for larger images I am passing the height and width values
into the subroutine directly.
'-----

Testing this out with 255X255, 256X256 and 513X513 pixel bitmaps seems
to suggest:

lngPixelWidth = Asc(Mid(strL1, 20, 1)) * 256 + Asc(Mid(strL1, 19, 1))
lngPixelHeight = Asc(Mid(strL1, 24, 1)) * 256 + Asc(Mid(strL1, 23, 1))

instead of:

lngPixelWidth = Asc(Mid(strL1, 21, 1)) * 16 + Asc(Mid(strL1, 19, 1))
lngPixelHeight = Asc(Mid(strL1, 25, 1)) * 16 + Asc(Mid(strL1, 23, 1))

Getting the image attributes of .bmp files automatically for images
with a dimension larger than 255 pixels instead of passing the value in
will help me streamline the process of putting image streams into
Access generated PDF files.

BTW, here's a function I omitted in the original post:
'----
Public Function HexToDecimal(st rIn As String) As Long
Dim intTemp As String
Dim strTemp As String

'This function assumes input is a single character
strTemp = UCase(strIn)
Select Case strTemp
Case "0" To "9": intTemp = Asc(strIn) - 48
Case "A" To "F": intTemp = Asc(strIn) - 55
Case Else:
MsgBox ("Non-hexadecimal input to function HexToDecimal.")
intTemp = 0
End Select
HexToDecimal = CLng(intTemp)
End Function
'-----

I have not discovered any other errors in this code, but note that I
have not tried to find out what happens in the PDF file if I put a
space after the final pixel value in the output stream. I hope to be
able to show an example of using this technique, for both compressed
and uncompressed streams, to place an image in a PDF file. I am able
to do both now, but compression takes too many steps in its present
form and obtaining and using an uncompressed stream can cause the PDF
file to take a couple of seconds or more to appear. The compressed
image streams produce PDF files that are quite compact. In addition,
if an image will show up on every page, the existing compressed stream
stored once in the PDF file can be used repeatedly with only a small
amount of text used to translate, scale and display the image. For
example:

q
1 0 0 1 36 770 cm
125 0 0 -90.981 0 0 cm
/ImLogo Do
Q

The image object seems to be represented as an upside down 1 X 1 point
that is scaled to the required size, so images take slightly more
planning to get the origin correct in the PDF output file.

James A. Fortune
CD********@Fort uneJames.com

Jul 23 '06 #1
0 1671

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

Similar topics

3
4660
by: CanyonJ | last post by:
I've been running into a frustrating problem for a while now. I use image.FromStream to open a tif, then perform some drawstring methods, and then save the file again. The tiffs are in 1 bit per pixel format, so there is some compression going on when we save the file. Quite a few files are opened and closed. Everything seems to work fine for a couple hours. The only draw back is the cpu is generally at 100%. Then the code starts...
1
4382
by: John Scott | last post by:
I am storing an image in an SQL database and have one field as an image datatype. I am also using a webservice to transport data. I want to be able to resize the image and pass back a thumbnail image in a byte of what is in the database. I also want to be able to display this image in an <asp:image></asp:image> control. Is there any way to do this? Most of the examples that I've seen have used
6
3473
by: Arnold | last post by:
Hi there, I've looked at numerous posts out there but have yet to find a solution to this. I have an image control on a main form that shows a linked jpeg thumbnail. Image controls are also on 2 subforms that also show linked thumbnails. When the user initially selects a jpeg from the Windows API Common Dialog Control, the image needs to immediately appear. I have the following code on the main form:
1
4672
by: Fahad Aijaz | last post by:
Hi, I am trying to display a Png image via ASP .NET. I get the image from the stream, creates the Bitmap, set the content type to Image/Png, but it give an error. If I set the content type to Image/Jpeg it works really fine. Below is the code I wrote and the error msg: ********************************************************** ERROR **********************************************************
2
1837
by: TC | last post by:
Is there any way to save a bitmap in an uncompressed format which preserves transparency? The BMP format is uncompressed, but doesn't support transparency. The GIF format has an alpha channel, but always uses compression. The TIFF format preserves transparency and has an option for no compression, but that option doesn't seem to be supported by VB.NET. I'm intrigued by the image format called MemoryBMP; I'd like to test it out, but every...
6
4568
by: Corobori | last post by:
I am writing a vb.net application where I need to store image in a SQL Server database, yes I know I shouldn't but my clients wants it and has his reasons to do so. In order to reduce the database size I was wondering how I could compress the image (coming from a scan made by Pegasus TwainPro). I saw some possibility in the TwainPro doc but the samples do not contain much description. I was thinking of using Xceed Streaming Compression to...
9
8766
by: Tom John | last post by:
Hi I am storing images in an access database, based on an MSDN article. The code i use to store is as follows: <code> 'Create the command object Dim command As New OleDbCommand("ImageBlobUpdate", dataConnection) Command.CommandType = CommandType.StoredProcedure)
2
4121
by: Adam Teale | last post by:
hey guys Is there a builtin/standard install method in python for retrieving or finding out an image's dimensions? A quick google found me this: http://www.pythonware.com/library/pil/handbook/introduction.htm but it looks like it is something I will need to install - I'd like to be able to pass my script around to people without them needing any
1
3480
by: Sumeet | last post by:
Hi All, I have taken an db2 v8.1 fp15 backup on AIX and want to restore it into a db2 v8.1 fp15 Solaris Box. If the backup was uncompressed, the cross-platform restore works without any issue. But for compressed backup images, since the decompression requires compression libraries, which I assume, is in native AIX binary code(and embedded into the image), it fails to restore the database. Could someone advise, if we can decompress the...
0
8272
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, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
8713
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
0
8514
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 protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
1
6126
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 presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
5579
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 then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
0
4094
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 last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
1
2632
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 we have to send another system
1
1817
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
2
1516
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

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.