473,406 Members | 2,356 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,406 software developers and data experts.

Issue with dynamic image saved in the database

I'm drawing dynamically on a bitmap.I want to be able to save the bitmap in the database as a JPG. I am using the following code to draw and get the bytes for the database. The image saved in the databse is always black, the bytes look the same even I am drawing different lines. What I am doing wrong? I try adding mIns.Flush(), and it is still not working.
Expand|Select|Wrap|Line Numbers
  1. Bitmap bmp = new Bitmap(328, 152);
  2. Graphics g = Graphics.FromImage(bmp);
  3. SolidBrush solidBrush;
  4. Pen pen;
  5. solidBrush = new SolidBrush(Color.Black);
  6. pen = new Pen(solidBrush);
  7. int oldx = 0;
  8. int oldy = 0;
  9. g.DrawLine(pen, oldx, oldy, 100, 100);
  10. solidBrush.Dispose();
  11. pen.Dispose();
  12. MemoryStream mIns = new MemoryStream();
  13. bmp.Save(mIns, System.Drawing.Imaging.ImageFormat.Jpeg);
  14. ret = new Byte[mIns.Length];
  15. mIns.Position = 0;
  16. mIns.Read(ret, 0, (int)mIns.Length);
  17.  
Thanks,
Ioana
Mar 19 '07 #1
2 1035
Forget about it. I was drawing with a black pen on a black surface.:o))
Mar 19 '07 #2
kenobewan
4,871 Expert 4TB
Thanks for sharing the solution :).
Mar 20 '07 #3

Sign in to post your reply or Sign up for a free account.

Similar topics

5
by: K | last post by:
I have found a script online that I want to use (I am new to PHP). It creates dynamic images based on the text that you pass it. However, no matter how I try, I can't get anything other than a...
2
by: Knoxy | last post by:
Hi there, Hope someone can help. I've had a look around on the web and found some useful info but not getting this to work... seen lots of different variations PROBLEM: ======== I have a...
7
by: lgbjr | last post by:
Hello All, I¡¯m using a context menu associated with some pictureboxes to provide copy/paste functionality. Copying the image to the clipboard was easy. But pasting an image from the clipboard...
9
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...
0
by: Ken | last post by:
Hi, Here is the problem that I am having. I work on an application which is a newsletter editor, you login and you are able to create newsletters based on templates. Everything works fine....
19
by: Materialised | last post by:
I have written the following code as a test, (yes I know it is a resource hog). Basically it pulls all images out of a MySQL table. <?php $conn = mysql_connect(host, user, pass);...
1
by: Oliphaunt182 | last post by:
I'm creating a dynamic webpage and I'm trying to load .gif picture however issues arise when I put part of the file and directory in a saved variable. Here is working code that pulls the image: ...
2
by: huntco | last post by:
Need to grab an image off the disk, preview in a picturebox, then save in SQL database for later viewing, etc. Got the "grab/preview" part working fine, and *something* is being stored in the...
4
by: BD | last post by:
I'm trying to build a hit counter that does what I want using an Access database named counters.mdb which contains 2 tables. The only one involved here is page_count. Here is the code for the...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
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
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
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,...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
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
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,...
0
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...

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.