Click here to Skip to main content
15,913,685 members
Home / Discussions / .NET (Core and Framework)
   

.NET (Core and Framework)

 
AnswerRe: ASPX files unaccessible now and then . Pin
Anmol.Gupta13-Aug-07 3:02
Anmol.Gupta13-Aug-07 3:02 
Question.Net framework compatibility Pin
pavya_Cool6-Aug-07 20:44
pavya_Cool6-Aug-07 20:44 
AnswerRe: .Net framework compatibility Pin
Pete O'Hanlon6-Aug-07 21:50
mvePete O'Hanlon6-Aug-07 21:50 
Questionredirect native dll printf output within .NET exe to a file Pin
chervu6-Aug-07 4:46
chervu6-Aug-07 4:46 
Questionproblem i displaying images Pin
ooooooooppppppss5-Aug-07 20:30
ooooooooppppppss5-Aug-07 20:30 
AnswerRe: problem i displaying images Pin
ne0h5-Aug-07 21:23
ne0h5-Aug-07 21:23 
JokeRe: problem i displaying images Pin
Luc Pattyn7-Aug-07 2:34
sitebuilderLuc Pattyn7-Aug-07 2:34 
Questionnewbie: Bitmap.CopyPixels with B/W images Pin
Daniele Fusi5-Aug-07 6:13
Daniele Fusi5-Aug-07 6:13 
Hi all,
I'm new to WPF and I'm experimenting with 3.0 bitmaps: I've created a dummy sample code which should:

1) load a bitmap file from disk. It's supposed to be a very small bitmap (e.g. 32x32, 200x100, etc), usually B/W.

2) convert the bitmap to B/W (if required) and get an array representing the black/white pixels.

For testing, I "dump" these pixels into a textbox with a fixed-pitch font (e.g. Courier New), by outputting a line for each bitmap row, where '.' represents the 'background' pixel (e.g. white) and '#' the foreground pixel (e.g. black). This way the textbox should give a sketch of the picture. This seems to work fine for non B/W bitmaps, and I can get the 'picture'; but as soon as I convert the loaded bitmap to B/W the textbox shows no more the 'picture', but this seems to be shrunken to occupy just a narrow leftmost portion of the dumped area. Also, I get a set of various values from CopyPixels in a B/W image, while I'd expect just 2, representing black and white. What am I doing wrong here? Here's a sample:

// load a bitmap eventually converting to B/W<br />
private BitmapSource LoadBitmap(string sFile, bool bConvertToBW)<br />
{<br />
  BitmapImage bmp = new BitmapImage(new Uri(sFile));<br />
  if (bConvertToBW)<br />
    return new FormatConvertedBitmap(bmp, PixelFormats.BlackWhite, BitmapPalettes.BlackAndWhite, 0);<br />
  return bmp;<br />
}<br />
<br />
// Handler for Load... button:<br />
private void OnLoad(object sender, RoutedEventArgs e)<br />
{<br />
  OpenFileDialog dlg = new OpenFileDialog();<br />
  dlg.Filter = "Bitmap Files (*.bmp)|*.bmp";<br />
  if (dlg.ShowDialog() != true) return;<br />
<br />
  // load (and convert to BW if required)<br />
  // IF I PASS true I GET THE ISSUE DESCRIBED ABOVE. WITH false THE DUMP SEEMS TO WORK<br />
  BitmapSource bs = LoadBitmap(dlg.FileName, true);<br />
<br />
  int nBytesPerPixel = (bs.Format.BitsPerPixel + 7) / 8;<br />
  int nStride = bs.PixelWidth * nBytesPerPixel;<br />
  byte[] aPixels = new byte[bs.PixelHeight * nStride];<br />
  bs.CopyPixels(aPixels, nStride, 0);<br />
<br />
  // quick and dirty dump pixels to text (BACKGROUND is just a constant I manually set to 0, 255 etc<br />
  // according to the image I'm testing with, and represents the background color)<br />
  StringBuilder sb = new StringBuilder();<br />
  int nRow;<br />
  for (int y = 0; y < bs.PixelHeight; y++)<br />
  {<br />
    if (y > 0) sb.AppendLine("");<br />
    nRow = y * nStride;<br />
    for (int x = 0; x < bs.PixelWidth; x++)<br />
      sb.Append(aPixels[nRow + x * nBytesPerPixel] == BACKGROUND ? '.' : '#');<br />
   }<br />
  _txtOut.Text = sb.ToString();<br />
}

Thanks!
QuestionDifference between win32 API and FCL Pin
addee2-Aug-07 10:45
addee2-Aug-07 10:45 
AnswerRe: Difference between win32 API and FCL Pin
Christian Graus2-Aug-07 22:41
protectorChristian Graus2-Aug-07 22:41 
GeneralRe: Difference between win32 API and FCL Pin
addee3-Aug-07 1:34
addee3-Aug-07 1:34 
Questionresources in exe? Pin
CherezZaboro2-Aug-07 7:26
CherezZaboro2-Aug-07 7:26 
AnswerRe: resources in exe? Pin
Luc Pattyn2-Aug-07 7:45
sitebuilderLuc Pattyn2-Aug-07 7:45 
GeneralRe: resources in exe? Pin
CherezZaboro2-Aug-07 8:08
CherezZaboro2-Aug-07 8:08 
GeneralRe: resources in exe? Pin
Luc Pattyn2-Aug-07 8:32
sitebuilderLuc Pattyn2-Aug-07 8:32 
GeneralRe: resources in exe? Pin
CherezZaboro2-Aug-07 9:35
CherezZaboro2-Aug-07 9:35 
AnswerRe: resources in exe? Pin
dekart_roo2-Aug-07 9:05
dekart_roo2-Aug-07 9:05 
GeneralRe: resources in exe? Pin
CherezZaboro2-Aug-07 9:37
CherezZaboro2-Aug-07 9:37 
Questionmac os x Pin
SomeGuyThatIsMe2-Aug-07 5:20
SomeGuyThatIsMe2-Aug-07 5:20 
AnswerRe: mac os x Pin
Kevin McFarlane2-Aug-07 5:46
Kevin McFarlane2-Aug-07 5:46 
GeneralRe: mac os x Pin
SomeGuyThatIsMe2-Aug-07 5:53
SomeGuyThatIsMe2-Aug-07 5:53 
GeneralRe: mac os x [modified] Pin
Kevin McFarlane2-Aug-07 6:20
Kevin McFarlane2-Aug-07 6:20 
GeneralRe: mac os x Pin
SomeGuyThatIsMe2-Aug-07 6:36
SomeGuyThatIsMe2-Aug-07 6:36 
GeneralRe: mac os x Pin
Kevin McFarlane2-Aug-07 7:03
Kevin McFarlane2-Aug-07 7:03 
GeneralRe: mac os x Pin
SomeGuyThatIsMe2-Aug-07 7:06
SomeGuyThatIsMe2-Aug-07 7:06 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.