Search Results

Search found 1375 results on 55 pages for 'bitmap'.

Page 4/55 | < Previous Page | 1 2 3 4 5 6 7 8 9 10 11 12  | Next Page >

  • Handling inverted pixels in bitmapData and bitmap class in as3

    - by intoTHEwild
    I am using bitmapData and bitmap classes to render a mouse cursor on the display screen. The bitmapData consists of an area whose colors should be inverted according to the background color. This is a very basic thing which could be observed with text cursor(the vertical line with two small horizontals on top and bottom), when moved over the text area. I want to be able to do the same with the pixels in my bitmapData, is there a way to find out the background color effectively and invert the color values? In this process i will be redrawing the whole pixels, is there any other efficient way to do that ?

    Read the article

  • Graphics/Bitmap Limits?

    - by Dean
    Im having some weird problems with Graphics and Bitmap. I have a Graphics Object that is displayed on a PictureBox and im capturing the MouseMove and MouseClick Events that give X and Y Position of the Mouse on the Image but if the Y Position goes Bigger then 32775 it then goes into Negatives which means everything breaks. And if the Image is Bigger then 65535 it then stops displaying the Image. Any Ideas how these problems can be fixed? Thanks Example Code: http://pastebin.com/YEX0XD1q Just Click Make 10,000 Bigger about 4 times then scroll down and on the right it will show the mouse X and Y position and as you move down through the image and hover over the Red Area if you go down enough it will go into Negative Y.

    Read the article

  • Bitmap in ImageView is cropped off the screen

    - by Computerish
    I'm working on an Android application that needs to download an image and display it inside an image view. The Bitmap is passed to the main java file and added to the image view like this: comic = (ImageView) findViewById(R.id.comic); comic.setImageBitmap(c.getImageBitmap()); This works, except that the left side of the image disappears off the screen. The ImageView is in a ScrollView and the scroll view maintains the correct size. This means that there is black space to the right in the ScrollView and the image is cut off to the left. The XML for the ImageView is this: <ScrollView android:layout_width="fill_parent" android:layout_height="fill_parent" Any idea why my image is being cut off? Thanks!

    Read the article

  • Bitmap Crashing upon going back and re-entering Activity

    - by dagonal
    Hello, I'm not sure what is causing this...I have two Activities, first has a button that goes to the second. The second creates a Bitmap object, assigns it a picture from the sdcard and loads it into an ImageView. Problem is when I go into the second Activity, then press the back button, and then go back into the second Activity, it crashes. I have no clue why. I did an extensive google search but to no avail. I can post the source code if you want. Please let me know. Thanks in advance! I got this from the LogCat: "E/dalvikvm( 4869): Unable to open stack trace file '/data/anr/traces.txt': Permission denied" I'm not sure how to get the stack trace.

    Read the article

  • Android: Is decreasing size of .png files have some effect to resulted Bitmap in memory

    - by nahab
    I'm writing game with a large amount of .png pictures. All worked fine. Than I added new activity with WebView and got memory shortage. After that I made some experiment - replace game .png images with ones that just fully filled with some color. As result memory shortage had gone. But I suppose that Bitmap internally hold each pixel separately so such changes should have no effect. Maybe this because of initial images have alpha channel and my test images have not it? But actually question is: Will decreasing .png images files sizes make some effect on decreasing usage of VM application heap or not?

    Read the article

  • Horizontally Flip a One Bit Bitmap Line

    - by roygbiv
    I'm looking for an algorithm to flip a 1 Bit Bitmap line horizontally. Remember these lines are DWORD aligned! I'm currently unencoding an RLE stream to an 8 bit-per-pixel buffer, then re-encoding to a 1 bit line, however, I would like to try and keep it all in the 1 bit space in an effort to increase its speed. Profiling indicates this portion of the program to be relatively slow compared to the rest. Example line (Before Flip): FF FF FF FF 77 AE F0 00 Example line (After Flip): F7 5E EF FF FF FF F0 00

    Read the article

  • Bitmap size exceeds VM budget after second load

    - by jonny
    This is driving me crazy. I have a game which has a bitmap as the background, this is big so I scale it down and this works fine. However when I navigate to another activity and then reload the game screen it crashes on drawing the background. I am calling recycle on all the bitmaps and setting them to null on onDestroy() but this doesn't help. Any ideas and if not how can I debug the memory to see at which step its growing. I looked at getting the heap but nothing of any size is on there really. Thanks.

    Read the article

  • How to convert Bitmap to byte[,,] faster?

    - by Miko Kronn
    I wrote function: public static byte[, ,] Bitmap2Byte(Bitmap image) { int h = image.Height; int w = image.Width; byte[, ,] result= new byte[w, h, 3]; for (int i = 0; i < w; i++) { for (int j = 0; j < h; j++) { Color c= image.GetPixel(i, j); result[i, j, 0] = c.R; result[i, j, 1] = c.G; result[i, j, 2] = c.B; } } return result; } But it takes almost 6 seconds to convert 1800x1800 image. Can I do this faster?

    Read the article

  • calling concurrently Graphics.Draw and new Bitmap from memory in thread take long time

    - by Abdul jalil
    Example1 public partial class Form1 : Form { public Form1() { InitializeComponent(); pro = new Thread(new ThreadStart(Producer)); con = new Thread(new ThreadStart(Consumer)); } private AutoResetEvent m_DataAvailableEvent = new AutoResetEvent(false); Queue<Bitmap> queue = new Queue<Bitmap>(); Thread pro; Thread con ; public void Producer() { MemoryStream[] ms = new MemoryStream[3]; for (int y = 0; y < 3; y++) { StreamReader reader = new StreamReader("image"+(y+1)+".JPG"); BinaryReader breader = new BinaryReader(reader.BaseStream); byte[] buffer=new byte[reader.BaseStream.Length]; breader.Read(buffer,0,buffer.Length); ms[y] = new MemoryStream(buffer); } while (true) { for (int x = 0; x < 3; x++) { Bitmap bmp = new Bitmap(ms[x]); queue.Enqueue(bmp); m_DataAvailableEvent.Set(); Thread.Sleep(6); } } } public void Consumer() { Graphics g= pictureBox1.CreateGraphics(); while (true) { m_DataAvailableEvent.WaitOne(); Bitmap bmp = queue.Dequeue(); if (bmp != null) { // Bitmap bmp = new Bitmap(ms); g.DrawImage(bmp,new Point(0,0)); bmp.Dispose(); } } } private void pictureBox1_Click(object sender, EventArgs e) { con.Start(); pro.Start(); } } when Creating bitmap and Drawing to picture box are in seperate thread then Bitmap bmp = new Bitmap(ms[x]) take 45.591 millisecond and g.DrawImage(bmp,new Point(0,0)) take 41.430 milisecond when i make bitmap from memoryStream and draw it to picture box in one thread then Bitmap bmp = new Bitmap(ms[x]) take 29.619 and g.DrawImage(bmp,new Point(0,0)) take 35.540 the code is for Example 2 is why it take more time to draw and bitmap take time in seperate thread and how to reduce the time when processing in seperate thread. i am using ANTS performance profiler 4.3 public Form1() { InitializeComponent(); pro = new Thread(new ThreadStart(Producer)); con = new Thread(new ThreadStart(Consumer)); } private AutoResetEvent m_DataAvailableEvent = new AutoResetEvent(false); Queue<MemoryStream> queue = new Queue<MemoryStream>(); Thread pro; Thread con ; public void Producer() { MemoryStream[] ms = new MemoryStream[3]; for (int y = 0; y < 3; y++) { StreamReader reader = new StreamReader("image"+(y+1)+".JPG"); BinaryReader breader = new BinaryReader(reader.BaseStream); byte[] buffer=new byte[reader.BaseStream.Length]; breader.Read(buffer,0,buffer.Length); ms[y] = new MemoryStream(buffer); } while (true) { for (int x = 0; x < 3; x++) { // Bitmap bmp = new Bitmap(ms[x]); queue.Enqueue(ms[x]); m_DataAvailableEvent.Set(); Thread.Sleep(6); } } } public void Consumer() { Graphics g= pictureBox1.CreateGraphics(); while (true) { m_DataAvailableEvent.WaitOne(); //Bitmap bmp = queue.Dequeue(); MemoryStream ms= queue.Dequeue(); if (ms != null) { Bitmap bmp = new Bitmap(ms); g.DrawImage(bmp,new Point(0,0)); bmp.Dispose(); } } } private void pictureBox1_Click(object sender, EventArgs e) { con.Start(); pro.Start(); }

    Read the article

  • VB.net Saving an MetaFile / EMF as a bitmap ( .tiff)

    - by pehaada
    Currently I have a third party control that generates a Metafile. I can save the .wmf file to disk with out issue. The problem is how do I render the Metafile as a Tiff file. Currently I have the following code to get my metafile and save it. Dim mf As Metafile = page.GetImage(TXTextControl.Page.PageContent.All) Dim enhMetafileHandle As IntPtr = mf.GetHenhmetafile() Dim h As IntPtr Dim bufferSize As UInteger = GetEnhMetaFileBits(enhMetafileHandle, 0, h) Dim buffer(CInt(bufferSize)) As Byte GetEnhMetaFileBits(enhMetafileHandle, bufferSize, buffer) Dim msMetafileStream As New MemoryStream msMetafileStream.Write(buffer, 0, CInt(bufferSize)) Dim baMetafileData() As Byte baMetafileData = msMetafileStream.ToArray Dim g As Graphics = Graphics.FromImage(mf) mf.Dispose() File.WriteAllBytes("c:\a.wmf", baMetafileData) end sub _ Public Shared Function GetEnhMetaFileBits( ByVal hEMF As System.IntPtr, ByVal nSize As UInteger, ByVal lpData As IntPtr) As UInteger End Function <System.Runtime.InteropServices.DllImportAttribute("gdi32.dll", EntryPoint:="GetEnhMetaFileBits")> _ Public Shared Function GetEnhMetaFileBits(<System.Runtime.InteropServices.InAttribute()> ByVal hEMF As System.IntPtr, ByVal nSize As UInteger, ByVal lpData() As Byte) As UInteger End Function I've tried all sort of IMAGE and Graphic calls and just can't save the meta file as a .tiff. Any suggestions would be great. I even tried to create a new bitmap and draw the metafile onto it. I always end up with a GDI exception being thrown.

    Read the article

  • Determining the color of a pixel in a bitmap using C# in a WPF app

    - by DanM
    The only way I found so far is System.Drawing.Bitmap.GetPixel(), but Microsoft has warnings for System.Drawing that are making me wonder if this is the "old way" to do it. Are there any alternatives? Here's what Microsoft says about the System.Drawing namespace. I also noticed that the System.Drawing assembly was not automatically added to the references when I created a new WPF project. System.Drawing Namespace The System.Drawing namespace provides access to GDI+ basic graphics functionality. More advanced functionality is provided in the System.Drawing.Drawing2D, System.Drawing.Imaging, and System.Drawing.Text namespaces. The Graphics class provides methods for drawing to the display device. Classes such as Rectangle and Point encapsulate GDI+ primitives. The Pen class is used to draw lines and curves, while classes derived from the abstract class Brush are used to fill the interiors of shapes. Caution Classes within the System.Drawing namespace are not supported for use within a Windows or ASP.NET service. Attempting to use these classes from within one of these application types may produce unexpected problems, such as diminished service performance and run-time exceptions. - http://msdn.microsoft.com/en-us/library/system.drawing.aspx

    Read the article

  • Optimization of a c++ matrix/bitmap class

    - by Andrew
    I am searching a 2D matrix (or bitmap) class which is flexible but also fast element access. The contents A flexible class should allow you to choose dimensions during runtime, and would look something like this (simplified): class Matrix { public: Matrix(int w, int h) : data(new int[x*y]), width(w) {} void SetElement(int x, int y, int val) { data[x+y*width] = val; } // ... private: // symbols int width; int* data; }; A faster often proposed solution using templates is (simplified): template <int W, int H> class TMatrix { TMatrix() data(new int[W*H]) {} void SetElement(int x, int y, int val) { data[x+y*W] = val; } private: int* data; }; This is faster as the width can be "inlined" in the code. The first solution does not do this. However this is not very flexible anymore, as you can't change the size anymore at runtime. So my question is: Is there a possibility to tell the compiler to generate faster code (like when using the template solution), when the size in the code is fixed and generate flexible code when its runtime dependend? I tried to achieve this by writing "const" where ever possible. I tried it with gcc and VS2005, but no success. This kind of optimization would be useful for many other similar cases.

    Read the article

  • Uri for bitmap in subfolder (c# wpf)

    - by the empirical programmer
    I have a wpf app where I'm using an image. To reference the image I use: Uri uri = new Uri("pack://application:,,,/assemblyName;Component/myIcon.png"); BitmapImage(uri) If I add the png directly under the csproj file (with its properties BuildAction=Resource) then it works fine. But I want to move it to a subfolder under the csproj. Another SO question asked about bitmaps\uri's (857732) and an answer linked to this msdn. So I tried : Uri uri = new Uri("pack://application:,,,/assemblyName;Component/Icons/myIcon.png"); But that did not work. Any ideas?

    Read the article

  • AS3 Flex masks with black background from png bitmap

    - by airlocker
    Hi all What I am trying to achieve might be trivial, however I am loading a PNG mask which does not have a transparent background, but rather a black background, with the shape defined on top in white (the actual mask which needs to be applied). Apparently Flex expects me to provide a mask with a transparent background for it to work, or am I missing something? If that's the case, could I transform the bitmapData which I am loading so that it treats black color as transparent? thanks in advance.

    Read the article

  • Android GridView - How to change a bitmap dynamically?

    - by Alborz
    Hello I have a gridView which I use to show some pictures on (small thumb of diffrent levels). When the user finishes one level, I would like to change the thumb for that level. (Somehow show that it has been completed). I created two thumbs for each level. One is the original and one that shows that the level is completed. But how can i change the source of the images? The code which I use to draw the images looks like this. The main activity: /** Called when the activity is first created. */ public void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.maps); GridView gridview = (GridView) findViewById(R.id.gridview); gridview.setAdapter(new ImageAdapter(this)); gridview.setOnItemClickListener(new OnItemClickListener() { @Override public void onItemClick(AdapterView<?> parent, View v, int position, long id) { //Open the map which was clicked on, if there is one if(position+1 > 1){ Toast.makeText(maps.this, "Level " + (position+1) + " is not yet available!", Toast.LENGTH_SHORT).show(); }else{ Toast.makeText(maps.this, "Opening Level " + (position+1), Toast.LENGTH_SHORT).show(); Intent myIntent = new Intent(v.getContext(), Tutorial2D.class); startActivity(myIntent); } } }); } The ImageAdapter Class: public class ImageAdapter extends BaseAdapter { private Context mContext; public ImageAdapter(Context c) { mContext = c; } public int getCount() { return mThumbIds.length; } public Object getItem(int position) { return null; } public long getItemId(int position) { return 0; } // create a new ImageView for each item referenced by the Adapter public View getView(int position, View convertView, ViewGroup parent) { ImageView imageView; if (convertView == null) { // if it's not recycled, initialize some attributes imageView = new ImageView(mContext); imageView.setLayoutParams(new GridView.LayoutParams(85, 85)); imageView.setScaleType(ImageView.ScaleType.CENTER_CROP); imageView.setPadding(8, 8, 8, 8); } else { imageView = (ImageView) convertView; } //Changing imageView.setImageResource(mThumbIds[position]); return imageView; } // references to our images private Integer[] mThumbIds = { R.drawable.map1, R.drawable.map2, R.drawable.map3, R.drawable.map4, R.drawable.map5, R.drawable.map6, R.drawable.map7, R.drawable.map8, R.drawable.map9, R.drawable.map10, R.drawable.map11, R.drawable.map12, R.drawable.map13, R.drawable.map14, R.drawable.map15, R.drawable.map16, R.drawable.map17, R.drawable.map18, R.drawable.map19 }; }

    Read the article

  • Load large images into Bitmap?

    - by GuyNoir
    I'm trying to make a basic application that displays an image from the camera, but I when I try to load the .jpg in from the sdcard with BitmapFactory.decodeFile, it returns null. It doesn't give an out of memory error which I find strange, but the exact same code works fine on smaller images. How does the generic gallery display huge pictures from the camera with so little memory?

    Read the article

  • Bitmap brightness issue in c++

    - by Suriyan Suresh
    I have used the following code to adjust the image brightness, i am testing this application in Samsung BADA Platform and its SDK, While i am running this application in bada simulator it never ends runs infinity. Please point out the mistake in the code int BitmapWidth = 0, BitmapHeight = 0; result r = E_SUCCESS; BufferInfo myBuffer; Osp::Media::Image *pImage = null; Osp::Graphics::Canvas *pCanvas = null; Osp::Graphics::Rectangle *pRect = null; String path("/Media/Images/tom1.jpg"); pImage = new Osp::Media::Image(); r = pImage->Construct(); pBitmap2 = pImage->DecodeN(path, BITMAP_PIXEL_FORMAT_ARGB8888,LCD_WIDTH, LCD_HEIGHT); BitmapWidth = pBitmap2->GetWidth(); BitmapHeight = pBitmap2->GetHeight(); pBitmap2->Lock( myBuffer); int nVal = 0; int stride = myBuffer.pitch; byte *p= (byte *)(void *)myBuffer.pPixels; int nWidth = BitmapWidth *3; int nOffset = stride - BitmapWidth*4; for (int y = 0; y < BitmapHeight; ++y) { for (int x = 0; x < nWidth; ++x) { nVal = (int) (p[0] + nBrightness); if (nVal < 0) nVal = 0; if (nVal > 255) nVal = 255; p[0] = (byte) nVal; ++p; } p+= nOffset; } pBitmap2->Unlock(); pCanvas = GetCanvasN(); // Step 3: Create Rectangle pRect = new Osp::Graphics::Rectangle(0, 0, LCD_WIDTH, LCD_HEIGHT); r = pCanvas->DrawBitmap(*pRect, *pBitmap2); pCanvas->Show(); RequestRedraw(true); delete pBitmap2; delete pCanvas; delete pRect;

    Read the article

  • Draw rectangle-like objects on a bitmap

    - by _simon_
    I am performing OCR (optical character recognition) on a bunch of images. Images are grouped into different projects (tickets, credit cards, insurance cards etc). Each image represents an actual product (for instance, if we have images of credit cards, picture1.jpg is image of my credit card, picture2.jpg is image of your credit card,... you get it). I have a settings.xml file, which contains regions of the image, where OCR should be performed. Example: <Project Name="Ticket1" TemplateImage="...somePath/templateTicket1.jpg"> <Region Name="Prefix" NumericOnly="false" Rotate="0"> <x>470</x> <y>395</y> <width>31</width> <height>36</height> </Region> <Region Name="Num1" NumericOnly="true" Rotate="0"> <x>555</x> <y>402</y> <width>123</width> <height>35</height> </Region> </Project> </Project Name="CreditCard" TemplateImage="...somePath/templateCreditCard1.jpg"> <Region Name="SerialNumber" NumericOnly="false" Rotate="90"> <x>332</x> <y>12</y> <width>20</width> <height>98</height> </Project> I would like to set these parameters through GUI (now I just write them into xml file). So, first I load a template image for a project (an empty credit card). Then I would like to draw a rectangle around a text, where OCR should be performed. I guess this isn't hard, but it would be great if I could also move and resize this rectangle object in the picture. I have to display all regions (rectangles) on the picture also. Also - there will probably be a list of regions in a listview, so when you click a region in this listview, it should mark it on the picture in a green color for example. Do you know for a library, which I could use? Or a link with some tips how to create such objects?

    Read the article

  • Resize an 8bpp bitmap in GDI+

    - by harry
    I've just noticed that GDI+ doesn't like the Graphics.FromImage() method to be called with an image that is 1bpp, 4bpp, or 8bpp. Is there any way of resizing an 8bpp image without changing from 8bpp to 24bpp, resizing, and then changing it back to 8bpp?

    Read the article

  • MD RAID 1 with external bitmap doesn't fully resync

    - by user64744
    I have an interesting configuration: dual boot system with a RAID 1 that needs to be visible in both Windows and Linux. The Windows install is Win 7 Enterprise, and the Linux install is Kubuntu 10.04. To get the RAID to work, I set it up using Windows's "Dynamic Disks" RAID 1, and brought it up in Linux using MD with no persistent superblock, and a write-intent bitmap on another partition. (Without this bitmap, MD had no way of knowing that the array was in sync, and would do a complete resync every time the array started.) The array is assembled like so: mdadm --build /dev/md1 -l 1 -n 2 -b /var/local/md1.bitmap /dev/sdb2 /dev/sdc2 I expected that the first time I ran this command, it would resync the array, write out a bitmap with no dirty chunks, and all would be good. This wasn't the case: after completing the resync, the bitmap was mostly clean, but about 5% dirty blocks remained, as revealed by mdadm -X /var/local/md1.bitmap I didn't mount the filesystem on /dev/md1 or touch it in any other way. I then found that stopping and restarting the array: mdadm --stop /dev/md1 mdadm --build /dev/md1 -l 1 -n 2 -b /var/local/md1.bitmap /dev/sdb2 /dev/sdc2 did indeed read in the bitmap, with an ensuing resync that went quickly because most of the blocks were marked clean. The confusing part is that this resync further reduced the number of dirty blocks, but still did not remove all of them. By repeatedly stopping and restarting I could slowly bring the dirty block count down to around 0.6%, where it seemed to level out. Any ideas what could be causing this? It smells to me of a race condition somewhere that leads to blocks either being skipped over during synchronization or not properly cleared from the bitmap, but I really have no evidence to prove this. It doesn't look like hardware issues since both drives are new and have zero read errors and reallocated sectors reported by smartctl -a.

    Read the article

  • How does Bitmap.Save(Stream, ImageFormat) format the data?

    - by Matt Jacobsen
    I have a non transparent, colour bitmap with length 2480 and width 3507. Using Bitmap.GetPixel(int x, int y) I am able to get the colour information of each pixel in the bitmap. If I squirt the bitmap into a byte[]: MemoryStream ms = new MemoryStream(); bmp.Save(ms, ImageFormat.Bmp); ms.Position = 0; byte[] bytes = ms.ToArray(); then I'd expect to have the same information, i.e. I can go to bytes[1000] and read the colour information for that pixel. It turns out that my array of bytes is larger than I anticipated. I thought I'd get an array with 2480 x 3507 = 8697360 elements. Instead I get an array with 8698438 elements - some sort of header I presume. In what format the bytes in my array stored? Is there a header 1078 bytes long followed by Alpha, Red, Green, Blue values for every byte element, or something else?

    Read the article

  • trying to copy a bitmap into the WMP Renderer -> upside down!

    - by Roey
    Hi All. I'm writing a video DMO decoder and trying to return a bitmap to the WMP renderer for display ... but WMP displays it upside down! This is the code : HBITMAP* hBmp = new HBITMAP(); int result; m_pScrRenderer->CreateFrame(hBmp, &result); ///This returns the HBITMAP handle. BITMAP bmStruct; memset(&bmStruct, 0, sizeof(BITMAP)); GetObject(*hBmp, sizeof(BITMAP), &bmStruct); int size = bmStruct.bmWidthBytes * bmStruct.bmHeight; memcpy(pbOutData, bmStruct.bmBits, size); //PBoutData is WMP's renderer buffer. This produces an upside down image. What should I change in this code? Thank You! Roey.

    Read the article

  • Sometimes, scaling down a bitmap generates a bigger file. Why?

    - by Matías
    Hello, I'm trying to write a method to reduce the size of any image 50% each time is called but I've found a problem. Sometimes, I end up with a bigger filesize while the image is really just half of what it was. I'm taking care of DPI and PixelFormat. What else am I missing? Thank you for your time. public Bitmap ResizeBitmap(Bitmap origBitmap, int nWidth, int nHeight) { Bitmap newBitmap = new Bitmap(nWidth, nHeight, origBitmap.PixelFormat); newBitmap.SetResolution(origBitmap.HorizontalResolution, origBitmap.VerticalResolution); using (Graphics g = Graphics.FromImage((Image)newBitmap)) { g.InterpolationMode = InterpolationMode.HighQualityBicubic; g.DrawImage(origBitmap, 0, 0, nWidth, nHeight); } return newBitmap; }

    Read the article

< Previous Page | 1 2 3 4 5 6 7 8 9 10 11 12  | Next Page >